Issue 114368
Summary Clang crashes or hangs with unsigned long long int
Labels clang
Assignees
Reporter ZitongZhouEric
    Clang trunk crashes on this code:
To reproduce: https://godbolt.org/z/KdKh74q3W
```c
const union  { 
    struct  { 
        char x  [0x10000000ULL];  
        char y  [4];   
    }; 
}     
u = { { "0", "0"}};   
int main  ( )   { 
    return 0;    
}
```

```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.	<eof> parser at end of file
2.	Code generation
 #0 0x000000000396eb08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x396eb08)
 #1 0x000000000396c6cc SignalHandler(int) Signals.cpp:0:0
 #2 0x0000720dea442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000720dea514887 __write (/lib/x86_64-linux-gnu/libc.so.6+0x114887)
 #4 0x0000000003945cea llvm::raw_fd_ostream::write_impl(char const*, unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3945cea)
 #5 0x0000000003946ba5 llvm::raw_ostream::write(char const*, unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3946ba5)
 #6 0x00000000038c945d llvm::formatted_raw_ostream::write_impl(char const*, unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38c945d)
 #7 0x0000000003946ab2 llvm::raw_ostream::write(char const*, unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3946ab2)
 #8 0x0000000003675b74 llvm::MCSectionELF::printSwitchToSection(llvm::MCAsmInfo const&, llvm::Triple const&, llvm::raw_ostream&, unsigned int) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3675b74)
 #9 0x00000000036d91dd (anonymous namespace)::MCAsmStreamer::changeSection(llvm::MCSection*, unsigned int) MCAsmStreamer.cpp:0:0
#10 0x000000000367956b llvm::MCStreamer::switchSection(llvm::MCSection*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x367956b)
#11 0x000000000482b99b llvm::AsmPrinter::doFinalization(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x482b99b)
#12 0x00000000032da93d llvm::FPPassManager::doFinalization(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x32da93d)
#13 0x00000000032e6070 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x32e6070)
#14 0x0000000003c08fa5 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c08fa5)
#15 0x00000000042b4a14 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x42b4a14)
#16 0x00000000062afb6c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x62afb6c)
#17 0x00000000042b5135 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x42b5135)
#18 0x000000000457de71 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x457de71)
#19 0x00000000044fdd3b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x44fdd3b)
#20 0x0000000004662293 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4662293)
#21 0x0000000000cebe0c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xcebe0c)
#22 0x0000000000ce486d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#23 0x00000000042fcf59 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#24 0x00000000038bdc23 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38bdc23)
#25 0x00000000042fd179 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#26 0x00000000042c4b1d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x42c4b1d)
#27 0x00000000042c5b1d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x42c5b1d)
#28 0x00000000042cf0cc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x42cf0cc)
#29 0x0000000000ce8b61 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xce8b61)
#30 0x0000000000bb9fc4 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xbb9fc4)
#31 0x0000720dea429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#32 0x0000720dea429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#33 0x0000000000ce430e _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xce430e)
fatal error: error in backend: IO failure on output stream: File too large
Compiler returned: 1
```

Increasing the ULL causes the clang to hang
```c
const union  { 
    struct  { 
        char x  [0x100000000ULL];  
 char y  [4];   
    };   
}     
u = { { "0", "0"}};   
int main  ( )   { 
    return 0;    
}
```
```
Program terminated with signal: SIGKILL
Compiler returned: 137
```

Verified both works fine with gcc.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to