Open
Description
clang-20 crashed with alias
attribute and constructor
attribute at -O1
and above.
Compiler explorer: https://godbolt.org/z/5bqxWjPE5
$cat mutant.c
int a() __attribute__((alias("foo")));
void foo() {}
int __attribute__((constructor)) main() { return a(); }
Also crashed at Clang-19.
$clang-19 -O1 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: /usr/lib/llvm-19/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mutant.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/code/reduce -fcoverage-compilation-dir=/home/code/reduce -resource-dir /usr/lib/llvm-19/lib/clang/19 -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O1 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-b4e528.o -x c mutant.c
1. <eof> parser at end of file
2. Optimizer
3. Running pass "globalopt" on module "mutant.c"
#0 0x00007fd9274c7246 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea7246)
#1 0x00007fd9274c4e20 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea4e20)
#2 0x00007fd9274c790b (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea790b)
#3 0x00007fd9260ff520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007fd92898d6d2 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x236d6d2)
#5 0x00007fd92898da27 llvm::ConstantFoldConstant(llvm::Constant const*, llvm::DataLayout const&, llvm::TargetLibraryInfo const*) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x236da27)
#6 0x00007fd9280dc480 llvm::Evaluator::EvaluateBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true, llvm::BasicBlock>, false, false>, llvm::BasicBlock*&, bool&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1abc480)
#7 0x00007fd9280dd062 llvm::Evaluator::EvaluateFunction(llvm::Function*, llvm::Constant*&, llvm::SmallVectorImpl<llvm::Constant*> const&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1abd062)
#8 0x00007fd92868c5d0 (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x206c5d0)
#9 0x00007fd9280caae8 llvm::optimizeGlobalCtorsList(llvm::Module&, llvm::function_ref<bool (unsigned int, llvm::Function*)>) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1aaaae8)
#10 0x00007fd928684442 llvm::GlobalOptPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x2064442)
#11 0x00007fd92a78822d (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x416822d)
#12 0x00007fd92764cb99 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x102cb99)
#13 0x00007fd92ffda091 (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x1e28091)
#14 0x00007fd92ffd293b 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*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x1e2093b)
#15 0x00007fd930378132 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x21c6132)
#16 0x00007fd92ede1739 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0xc2f739)
#17 0x00007fd930e740b5 clang::FrontendAction::Execute() (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2cc20b5)
#18 0x00007fd930de42f4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2c322f4)
#19 0x00007fd930ef0dee clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2d3edee)
#20 0x0000562ddfad5bc5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-19/bin/clang+0x11bc5)
#21 0x0000562ddfad2ad5 (/usr/lib/llvm-19/bin/clang+0xead5)
#22 0x0000562ddfad1c9b clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-19/bin/clang+0xdc9b)
#23 0x0000562ddfadff36 main (/usr/lib/llvm-19/bin/clang+0x1bf36)
#24 0x00007fd9260e6d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#25 0x00007fd9260e6e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#26 0x0000562ddfad0765 _start (/usr/lib/llvm-19/bin/clang+0xc765)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 19.0.0 (++20240722031324+65825cd5431c-1~exp1~20240722151445.1819)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-19/bin
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/mutant-91e178.c
clang: note: diagnostic msg: /tmp/mutant-91e178.sh
clang: note: diagnostic msg:
********************