Skip to content

Clang-18 crash when compiled with -c. #74464

@iamanonymouscs

Description

@iamanonymouscs

Clang-18 with -c crashes on the test case.
Compiler explorer: https://godbolt.org/z/KP9xxjE7e

$cat mutant.c extern char x[], y[], z[]; void func (void) { __atomic_exchange (&x, &y, &z, 0); } $clang-18 -c mutant.c 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: clang-18 -c mutant.c 1. <eof> parser at end of file 2. mutant.c:4:1: LLVM IR generation of declaration 'func' 3. mutant.c:4:1: Generating code for declaration 'func' #0 0x00007fa71a5f7266 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd2b266) #1 0x00007fa71a5f5170 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd29170) #2 0x00007fa71a5f68c4 llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xd2a8c4) #3 0x00007fa71a544bb0 (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc78bb0) #4 0x00007fa7250d8980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980) #5 0x00007fa722ded116 clang::CodeGen::CodeGenFunction::EmitAtomicExpr(clang::AtomicExpr*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1af1116) #6 0x00007fa7230119b5 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1d159b5) #7 0x00007fa723009bdd clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1d0dbdd) #8 0x00007fa722fb9ce9 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1cbdce9) #9 0x00007fa72311251f clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e1651f) #10 0x00007fa72311f4dc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e234dc) #11 0x00007fa7231795ba clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e7d5ba) #12 0x00007fa72317a22f clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e7e22f) #13 0x00007fa72319a0e5 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e9e0e5) #14 0x00007fa723193bf1 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e97bf1) #15 0x00007fa72319792d clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e9b92d) #16 0x00007fa7231928e2 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e968e2) #17 0x00007fa72322e75c (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1f3275c) #18 0x00007fa72316fefe (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x1e73efe) #19 0x00007fa721d8c93a clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0xa9093a) #20 0x00007fa723be4645 clang::FrontendAction::Execute() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x28e8645) #21 0x00007fa723b62cc4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x2866cc4) #22 0x00007fa723c5f1c0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x29631c0) #23 0x000055f1d6a97837 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-18/bin/clang+0x13837) #24 0x000055f1d6a94905 (/usr/lib/llvm-18/bin/clang+0x10905) #25 0x00007fa7237fa909 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24fe909) #26 0x00007fa71a54494c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm-18/bin/../lib/libLLVM-18.so.1+0xc7894c) #27 0x00007fa7237fa2ae clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24fe2ae) #28 0x00007fa7237c20f1 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24c60f1) #29 0x00007fa7237c233e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24c633e) #30 0x00007fa7237de39c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18+0x24e239c) #31 0x000055f1d6a9425c clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-18/bin/clang+0x1025c) #32 0x000055f1d6aa1f32 main (/usr/lib/llvm-18/bin/clang+0x1df32) #33 0x00007fa718adbc87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0 #34 0x000055f1d6a911ea _start (/usr/lib/llvm-18/bin/clang+0xd1ea) clang-18: error: clang frontend command failed with exit code 136 (use -v to see invocation) Ubuntu clang version 18.0.0 (++20231018091808+48a53509e851-1~exp1~20231018091910.1571) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin clang-18: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-18: note: diagnostic msg: /tmp/mutant-fa8676.c clang-18: note: diagnostic msg: /tmp/mutant-fa8676.sh clang-18: note: diagnostic msg: ******************** 

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions