llvm / llvm/llvm-project

clang++-22 segfaults in AsmPrinter::preprocessXXStructorList when compiling OpenMP code (-fopenmp=libomp)

Open
#213,520 22 comments 0 reactions 0 assignees View on GitHub
crash llvm:codegen needs-reduction openmp
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Stack dump:
```
0. Program arguments: /usr/bin/clang++-22 -DKOKKOS_DEPENDENCE -I/local/home/tpadiole/Codes/gyselalibxx/src/speciesinfo -I/local/home/tpadiole/Codes/gyselalibxx/src/io -I/local/home/tpadiole/Codes/gyselalibxx/src/data_types -I/local/home/tpadiole/Codes/gyselalibxx/src/utils -I/local/home/tpadiole/Codes/gyselalibxx/src/paraconfpp -isystem /local/home/tpadiole/spack-1.2.2/var/spack/environments/gyselalibxx-clang-omp/.spack-env/view/ddc-0.15.1-bbkwu6gjtwysznwenj4ijgstr7ohzjvu/include -isystem /local/home/tpadiole/spack-1.2.2/var/spack/environments/gyselalibxx-clang-omp/.spack-env/view/kokkos-5.1.1-75k3qfbinsgluddozkf53rbdbeaodfzf/include -isystem /local/home/tpadiole/spack-1.2.2/var/spack/environments/gyselalibxx-clang-omp/.spack-env/view/python-3.14.5-67h5gf3sgjhmxqvat5azal6kywrvfzd2/include -isystem /local/home/tpadiole/spack-1.2.2/var/spack/environments/gyselalibxx-clang-omp/.spack-env/view/paraconf-1.0.4-g36uo2xete2qfcsp33mb5wtrmfqmxqqg/include -isystem /local/home/tpadiole/spack-1.2.2/opt/spack/linux-x86_64/libyaml-0.2.5-zoxxo5kfemim2sowi3dud4ptqubzgkei/include -std=gnu++20 -fopenmp=libomp -MD -MT src/speciesinfo/CMakeFiles/speciesinfo.dir/species_init.cpp.o -MF CMakeFiles/speciesinfo.dir/species_init.cpp.o.d -o CMakeFiles/speciesinfo.dir/species_init.cpp.o -c /local/home/tpadiole/Codes/gyselalibxx/src/speciesinfo/species_init.cpp
1. parser at end of file
2. Code generation
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 libLLVM.so.22.1 0x000072ff0c5a0a9f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 63
1 libLLVM.so.22.1 0x000072ff0c59e317 llvm::sys::RunSignalHandlers() + 135
2 libLLVM.so.22.1 0x000072ff0c4cc057
3 libc.so.6 0x000072ff07045cb0
4 libLLVM.so.22.1 0x000072ff0c77c4e9 llvm::Value::stripPointerCasts() const + 41
5 libLLVM.so.22.1 0x000072ff0cfdca75 llvm::AsmPrinter::preprocessXXStructorList(llvm::DataLayout const&, llvm::Constant const*, llvm::SmallVector&) + 181
6 libLLVM.so.22.1 0x000072ff0cfdce7d llvm::AsmPrinter::emitXXStructorList(llvm::DataLayout const&, llvm::Constant const*, bool) + 93
7 libLLVM.so.22.1 0x000072ff0cfd02ba llvm::AsmPrinter::emitSpecialLLVMGlobal(llvm::GlobalVariable const*) + 1258
8 libLLVM.so.22.1 0x000072ff0cfcf4f5 llvm::AsmPrinter::emitGlobalVariable(llvm::GlobalVariable const*) + 165
9 libLLVM.so.22.1 0x000072ff0cfd97f0 llvm::AsmPrinter::doFinalization(llvm::Module&) + 1216
10 libLLVM.so.22.1 0x000072ff0c71af21 llvm::FPPassManager::doFinalization(llvm::Module&) + 65
11 libLLVM.so.22.1 0x000072ff0c716001 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1377
12 libclang-cpp.so.22.1 0x000072ff12f599f7 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::unique_ptr>, clang::BackendConsumer*) + 5031
13 libclang-cpp.so.22.1 0x000072ff1327d8e7 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1767
14 libclang-cpp.so.22.1 0x000072ff11d2d909 clang::ParseAST(clang::Sema&, bool, bool) + 617
15 libclang-cpp.so.22.1 0x000072ff13a78d42 clang::FrontendAction::Execute() + 50
16 libclang-cpp.so.22.1 0x000072ff139edc74 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 948
17 libclang-cpp.so.22.1 0x000072ff13b067aa clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 746
18 clang++-22 0x0000653621cb37ba cc1_main(llvm::ArrayRef, char const*, void*) + 6826
19 clang++-22 0x0000653621cb019a
20 clang++-22 0x0000653621cb1c50
21 libclang-cpp.so.22.1 0x000072ff136a3c82
22 libLLVM.so.22.1 0x000072ff0c4cbcd7 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) + 151
23 libclang-cpp.so.22.1 0x000072ff136a36c6 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const + 406
24 libclang-cpp.so.22.1 0x000072ff13662942 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 546
25 libclang-cpp.so.22.1 0x000072ff13662b1f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const + 143
26 libclang-cpp.so.22.1 0x000072ff13683e96 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) + 406
27 clang++-22 0x0000653621cafc77 clang_main(int, char**, llvm::ToolContext const&) + 6343
28 clang++-22 0x0000653621cbdf83 main + 131
29 libc.so.6 0x000072ff0702a601
30 libc.so.6 0x000072ff0702a718 __libc_start_main + 136
31 clang++-22 0x0000653621cade75 _start + 37
```
clang++-22: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 22.1.2 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-22/bin
clang++-22: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++-22: note: diagnostic msg: [species_init-7de5cc.cpp](https://github.com/user-attachments/files/30630090/species_init-7de5cc.cpp)
clang++-22: note: diagnostic msg: [species_init-7de5cc.sh](https://github.com/user-attachments/files/30630092/species_init-7de5cc.sh)
clang++-22: note: diagnostic msg:

********************

Note that clang++-22 compiles fine without OpenMP and the same code also compiles fine with GCC 15 with and without OpenMP.

Contributor guide

Open the contributing guide

Research direction

Start by running the attached species_init-7de5cc.sh script with species_init-7de5cc.cpp using clang++-22 and -fopenmp=libomp. Trace the crash through AsmPrinter::preprocessXXStructorList and compare with compilation without OpenMP and with GCC 15. Done means the reported OpenMP compilation no longer segfaults.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.