Clang 19 crash when building LLVM-libc complex f128 tests
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Ran into a clang crash when building LLVM-libc with some experimental cmake changes. Here's the logs and such. I've also included the git diff for the cmake (the base LLVM project commit was `2797688887217adefeb57fa589b803aceaea051d`). The commands I ran with that diff are:
`cmake ../runtimes -G Ninja -DLLVM_ENABLE_RUNTIMES="libc;compiler-rt" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_LIBC_FULL_BUILD=ON -DLLVM_LIBC_INCLUDE_SCUDO=ON -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON -DCOMPILER_RT_BUILD_GWP_ASAN=OFF -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/google/home/michaelrj/install`
then `ninja check-libc`
There were several similar crashes, on `crealf128_test`, `cprojf128_test`, `cprojf128_test`, `crealf128_test`, `conjf128_test`, `conjf128_test`, and `cimagf128_test` (the one attached).
```
[4027/13019] Building CXX object libc/test/src/complex/CMak...agf128_test.__hermetic__.__build__.dir/cimagf128_test.cpp.
FAILED: libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf128_test.__hermetic__.__build__.dir/cimagf128_test.cpp.o
/usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_22_0_0_git -I/usr/local/google/home/michaelrj/llvm-project/libc -isystem /usr/local/google/home/michaelrj/llvm-project/build-whatever/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=gnu++17 -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_COPT_STRING_LENGTH_IMPL=clang_vector -DLIBC_COPT_FIND_FIRST_CHARACTER_IMPL=word -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -DLIBC_FULL_BUILD -ffreestanding -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ffixed-point -Wall -Wextra -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -DLIBC_TEST=HERMETIC -DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=100 -DLIBC_COPT_TIMEOUT_ENSURE_MONOTONICITY=1 -MD -MT libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf128_test.__hermetic__.__build__.dir/cimagf128_test.cpp.o -MF libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf128_test.__hermetic__.__build__.dir/cimagf128_test.cpp.o.d -o libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf128_test.__hermetic__.__build__.dir/cimagf128_test.cpp.o -c /usr/local/google/home/michaelrj/llvm-project/libc/test/src/complex/cimagf128_test.cpp
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/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_22_0_0_git -I/usr/local/google/home/michaelrj/llvm-project/libc -isystem /usr/local/google/home/michaelrj/llvm-project/build-whatever/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=gnu++17 -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_COPT_STRING_LENGTH_IMPL=clang_vector -DLIBC_COPT_FIND_FIRST_CHARACTER_IMPL=word -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -fpie -DLIBC_FULL_BUILD -ffreestanding -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ffixed-point -Wall -Wextra -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -DLIBC_TEST=HERMETIC -DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=100 -DLIBC_COPT_TIMEOUT_ENSURE_MONOTONICITY=1 -MD -MT libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf128_test.__hermetic__.__build__.dir/cimagf128_test.cpp.o -MF libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf128_test.__hermetic__.__build__.dir/cimagf128_test.cpp.o.d -o libc/test/src/complex/CMakeFiles/libc.test.src.complex.cimagf128_test.__hermetic__.__build__.dir/cimagf128_test.cpp.o -c /usr/local/google/home/michaelrj/llvm-project/libc/test/src/complex/cimagf128_test.cpp
1. parser at end of file
2. Optimizer
3. Running pass "require,function(invalidate),require,cgscc(devirt<4>(inline,function-attrs,argpromotion,openmp-opt-cgscc,function(sroa,early-cse,speculative-execution,jump-threading,correlated-propagation,simplifycfg,instcombine,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm,loop-rotate,licm,simple-loop-unswitch),simplifycfg,instcombine,loop(loop-idiom,indvars,simple-loop-unswitch,loop-deletion,loop-unroll-full),sroa,vector-combine,mldst-motion,gvn<>,sccp,bdce,instcombine,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm),coro-elide,simplifycfg,instcombine),function-attrs,function(require),coro-split)),function(invalidate),cgscc(devirt<4>())" on module "/usr/local/google/home/michaelrj/llvm-project/libc/test/src/complex/cimagf128_test.cpp"
4. Running pass "cgscc(devirt<4>(inline,function-attrs,argpromotion,openmp-opt-cgscc,function(sroa,early-cse,speculative-execution,jump-threading,correlated-propagation,simplifycfg,instcombine,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm,loop-rotate,licm,simple-loop-unswitch),simplifycfg,instcombine,loop(loop-idiom,indvars,simple-loop-unswitch,loop-deletion,loop-unroll-full),sroa,vector-combine,mldst-motion,gvn<>,sccp,bdce,instcombine,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm),coro-elide,simplifycfg,instcombine),function-attrs,function(require),coro-split))" on module "/usr/local/google/home/michaelrj/llvm-project/libc/test/src/complex/cimagf128_test.cpp"
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.19.1 0x00007f35e56b067a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 58
1 libLLVM.so.19.1 0x00007f35e56ae224 llvm::sys::RunSignalHandlers() + 84
2 libLLVM.so.19.1 0x00007f35e55f4144
3 libc.so.6 0x00007f35e4249df0
4 libLLVM.so.19.1 0x00007f35e6bb290a
5 libLLVM.so.19.1 0x00007f35e6baf6ac llvm::ConstantFoldCall(llvm::CallBase const*, llvm::Function*, llvm::ArrayRef, llvm::TargetLibraryInfo const*, bool) + 316
6 libLLVM.so.19.1 0x00007f35e6c1e1d3
7 libLLVM.so.19.1 0x00007f35e6c199a1
8 libLLVM.so.19.1 0x00007f35e6c1576b
9 libLLVM.so.19.1 0x00007f35e6c149ef llvm::getInlineCost(llvm::CallBase&, llvm::Function*, llvm::InlineParams const&, llvm::TargetTransformInfo&, llvm::function_ref, llvm::function_ref, llvm::function_ref, llvm::ProfileSummaryInfo*, llvm::OptimizationRemarkEmitter*) + 319
10 libLLVM.so.19.1 0x00007f35e6c1489f llvm::getInlineCost(llvm::CallBase&, llvm::InlineParams const&, llvm::TargetTransformInfo&, llvm::function_ref, llvm::function_ref, llvm::function_ref, llvm::ProfileSummaryInfo*, llvm::OptimizationRemarkEmitter*) + 159
11 libLLVM.so.19.1 0x00007f35e6c24b5c
12 libLLVM.so.19.1 0x00007f35e6c21c7b llvm::shouldInline(llvm::CallBase&, llvm::function_ref, llvm::OptimizationRemarkEmitter&, bool) + 75
13 libLLVM.so.19.1 0x00007f35e6c2122b
14 libLLVM.so.19.1 0x00007f35e6c20fae llvm::DefaultInlineAdvisor::getAdviceImpl(llvm::CallBase&) + 62
15 libLLVM.so.19.1 0x00007f35e6c24361 llvm::InlineAdvisor::getAdvice(llvm::CallBase&, bool) + 225
16 libLLVM.so.19.1 0x00007f35e68c44d2 llvm::InlinerPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) + 3122
17 libLLVM.so.19.1 0x00007f35e68c8ba1
18 libLLVM.so.19.1 0x00007f35e6b91a07 llvm::PassManager, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) + 519
19 libLLVM.so.19.1 0x00007f35e68c9011
20 libLLVM.so.19.1 0x00007f35e6b93440 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) + 320
21 libLLVM.so.19.1 0x00007f35e68c95d1
22 libLLVM.so.19.1 0x00007f35e6b92b6f llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager&) + 2383
23 libLLVM.so.19.1 0x00007f35e68c93d1
24 libLLVM.so.19.1 0x00007f35e583c729 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) + 489
25 libLLVM.so.19.1 0x00007f35e68c64ec llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager&) + 604
26 libLLVM.so.19.1 0x00007f35e89fab11
27 libLLVM.so.19.1 0x00007f35e583c729 llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) + 489
28 libclang-cpp.so.19.1 0x00007f35ee4856f3
29 libclang-cpp.so.19.1 0x00007f35ee47cd9a clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr, std::unique_ptr>, clang::BackendConsumer*) + 6954
30 libclang-cpp.so.19.1 0x00007f35ee82a551 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1953
31 libclang-cpp.so.19.1 0x00007f35ed2344e9 clang::ParseAST(clang::Sema&, bool, bool) + 665
32 libclang-cpp.so.19.1 0x00007f35ef347789 clang::FrontendAction::Execute() + 89
33 libclang-cpp.so.19.1 0x00007f35ef2b6084 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1012
34 libclang-cpp.so.19.1 0x00007f35ef3c5c0e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 702
35 clang++ 0x0000560953b03c61 cc1_main(llvm::ArrayRef, char const*, void*) + 5905
36 clang++ 0x0000560953b00b35
37 libclang-cpp.so.19.1 0x00007f35eef354cd
38 libLLVM.so.19.1 0x00007f35e55f3ee0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) + 144
39 libclang-cpp.so.19.1 0x00007f35eef34f61 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const + 369
40 libclang-cpp.so.19.1 0x00007f35eeefa198 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 920
41 libclang-cpp.so.19.1 0x00007f35eeefa40e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const + 142
42 libclang-cpp.so.19.1 0x00007f35eef17bcc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) + 348
43 clang++ 0x0000560953b00574 clang_main(int, char**, llvm::ToolContext const&) + 6820
44 clang++ 0x0000560953b0e4ba main + 106
45 libc.so.6 0x00007f35e4233ca8
46 libc.so.6 0x00007f35e4233d65 __libc_start_main + 133
47 clang++ 0x0000560953afe731 _start + 33
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Debian clang version 19.1.7 (3+build5)
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/cimagf128_test-fa9fb3.cpp
clang++: note: diagnostic msg: /tmp/cimagf128_test-fa9fb3.sh
clang++: note: diagnostic msg:
********************
```
[cimagf128_test-fa9fb3.cpp](https://github.com/user-attachments/files/24109766/cimagf128_test-fa9fb3.cpp)
[cimagf128_test-fa9fb3.sh](https://github.com/user-attachments/files/24109764/cimagf128_test-fa9fb3.sh)
[libc_cmake_diff.txt](https://github.com/user-attachments/files/24109765/libc_cmake_diff.txt)
Contributor guide
Research direction
Reproduce the crash with the listed CMake configuration and `ninja check-libc`, focusing on `libc/test/src/complex/cimagf128_test.cpp` and the related f128 complex tests. Trace the optimizer and inliner stack shown in the report; done means the affected tests build without a Clang crash and the regression is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100