Compiler crash in the `CalledValuePropagationPass`
Describe the bug
The compiler crashes when using Cilksan and the manual flag -mllvm -cilksan-bc-path.
Expected behavior
I expect the compiler to compile the code. It works with OpenCilk 2.0.0.
OpenCilk version
- Release version: 2.1
- Distribution method:
.sharchive
System information
- OS: WSL 2.0: Ubuntu 22.04
- CPU: 11th Gen Intel(R) Core(TM) i9-11900H @ 2.50GHz
Steps to reproduce (include relevant output)
1. Preprocessed source:
2. Compile command:
3. Crash output:
clang++: /home/neboat/opencilk-project/llvm/include/llvm/Support/Casting.h:109: static bool llvm::isa_impl_cl<llvm::Instruction, const llvm::Value *>::doit(const From *) [To = llvm::Instruction, From = const llvm::Value *]: Assertion `Val && "isa<> used on a null pointer"' failed.
PLEASE submit a bug report to https://github.com/OpenCilk/opencilk-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/OpenCilk-2.1.0/bin/clang++ -DCILKSAN_ENABLED -DCILK_ENABLED -DSPDLOG_COMPILED_LIB -I/home/luka/clion/adaptive-hermite-refinement/cpp/lib -I/home/luka/clion/adaptive-hermite-refinement/cpp/cmake-build-debug-cilksan-workaround-21/_deps/mdspan-src/include -I/home/luka/clion/adaptive-hermite-refinement/cpp/fftw-cpp/include -I/home/luka/clion/adaptive-hermite-refinement/cpp/cmake-build-debug-cilksan-workaround-21/_deps/cnpy-src -I/home/luka/clion/adaptive-hermite-refinement/cpp/cmake-build-debug-cilksan-workaround-21/_deps/spdlog-src/include -I/home/luka/clion/adaptive-hermite-refinement/cpp/cmake-build-debug-cilksan-workaround-21/_deps/eve-src/include -gdwarf-4 -O1 -g -fopencilk -fsanitize=cilk -mllvm -cilksan-bc-path=/opt/OpenCilk-2.1.0/lib/clang/16/lib/x86_64-unknown-linux-gnu/libcilksan.bc -std=gnu++20 -MD -MT CMakeFiles/src-lib.dir/lib/Naive.cpp.o -MF CMakeFiles/src-lib.dir/lib/Naive.cpp.o.d -o CMakeFiles/src-lib.dir/lib/Naive.cpp.o -c /home/luka/clion/adaptive-hermite-refinement/cpp/lib/Naive.cpp
1. <eof> parser at end of file
2. Optimizer
#0 0x0000564e1fe5b607 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/OpenCilk-2.1.0/bin/clang+++0x4856607)
#1 0x0000564e1fe594be llvm::sys::RunSignalHandlers() (/opt/OpenCilk-2.1.0/bin/clang+++0x48544be)
#2 0x0000564e1fdda608 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f6173d67520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f6173dbba7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007f6173dbba7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007f6173dbba7c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007f6173d67476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007f6173d4d7f3 abort ./stdlib/abort.c:81:7
#9 0x00007f6173d4d71b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f6173d5ee96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x0000564e1f893189 (anonymous namespace)::CVPLatticeFunc::ComputeLatticeVal(llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>) CalledValuePropagation.cpp:0:0
#12 0x0000564e1f895a23 llvm::SparseSolver<llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, (anonymous namespace)::CVPLatticeVal, llvm::LatticeKeyInfo<llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>>>::getValueState(llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>) CalledValuePropagation.cpp:0:0
#13 0x0000564e1f894146 (anonymous namespace)::CVPLatticeFunc::ComputeInstructionState(llvm::Instruction&, llvm::DenseMap<llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, (anonymous namespace)::CVPLatticeVal, llvm::DenseMapInfo<llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, void>, llvm::detail::DenseMapPair<llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, (anonymous namespace)::CVPLatticeVal>>&, llvm::SparseSolver<llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, (anonymous namespace)::CVPLatticeVal, llvm::LatticeKeyInfo<llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>>>&) CalledValuePropagation.cpp:0:0
#14 0x0000564e1f895d46 llvm::SparseSolver<llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, (anonymous namespace)::CVPLatticeVal, llvm::LatticeKeyInfo<llvm::PointerIntPair<llvm::Value*, 2u, (anonymous namespace)::IPOGrouping, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 2u, llvm::PointerLikeTypeTraits<llvm::Value*>>>>>::visitInst(llvm::Instruction&) CalledValuePropagation.cpp:0:0
#15 0x0000564e1f8925c5 runCVP(llvm::Module&) CalledValuePropagation.cpp:0:0
#16 0x0000564e1f892060 llvm::CalledValuePropagationPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/OpenCilk-2.1.0/bin/clang+++0x428d060)
#17 0x0000564e2135140d llvm::detail::PassModel<llvm::Module, llvm::CalledValuePropagationPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilder.cpp:0:0
#18 0x0000564e1f753f15 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/OpenCilk-2.1.0/bin/clang+++0x414ef15)
#19 0x0000564e207ba716 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&) BackendUtil.cpp:0:0
#20 0x0000564e207b19d8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/opt/OpenCilk-2.1.0/bin/clang+++0x51ac9d8)
#21 0x0000564e20c8c829 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#22 0x0000564e220329a0 clang::ParseAST(clang::Sema&, bool, bool) (/opt/OpenCilk-2.1.0/bin/clang+++0x6a2d9a0)
#23 0x0000564e20ba67a0 clang::FrontendAction::Execute() (/opt/OpenCilk-2.1.0/bin/clang+++0x55a17a0)
#24 0x0000564e20b1660f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/OpenCilk-2.1.0/bin/clang+++0x551160f)
#25 0x0000564e20c85593 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/OpenCilk-2.1.0/bin/clang+++0x5680593)
#26 0x0000564e1e79f317 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/OpenCilk-2.1.0/bin/clang+++0x319a317)
#27 0x0000564e1e79ba1b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#28 0x0000564e20980a62 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::$_1>(long) Job.cpp:0:0
#29 0x0000564e1fdda34b llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/OpenCilk-2.1.0/bin/clang+++0x47d534b)
#30 0x0000564e209802a0 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/opt/OpenCilk-2.1.0/bin/clang+++0x537b2a0)
#31 0x0000564e20940e8e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/OpenCilk-2.1.0/bin/clang+++0x533be8e)
#32 0x0000564e2094113e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/OpenCilk-2.1.0/bin/clang+++0x533c13e)
#33 0x0000564e2095f610 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/OpenCilk-2.1.0/bin/clang+++0x535a610)
#34 0x0000564e1e79ab26 clang_main(int, char**) (/opt/OpenCilk-2.1.0/bin/clang+++0x3195b26)
#35 0x00007f6173d4ed90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#36 0x00007f6173d4ee40 call_init ./csu/../csu/libc-start.c:128:20
#37 0x00007f6173d4ee40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#38 0x0000564e1e797ba5 _start (/opt/OpenCilk-2.1.0/bin/clang+++0x3192ba5)
clang-16: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 16.0.6 ([email protected]:OpenCilk/opencilk-project.git 3f1a18993b8087b1b06c7e891dceec0c86016197)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/OpenCilk-2.1.0/bin
clang-16: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-16: note: diagnostic msg: /tmp/Naive-5cd90d.cpp
clang-16: note: diagnostic msg: /tmp/Naive-5cd90d.sh
clang-16: note: diagnostic msg:
********************
I'm having some trouble reproducing this crash on my end. Can you please share the file /opt/OpenCilk-2.1.0/lib/clang/16/lib/x86_64-unknown-linux-gnu/libcilksan.bc?
It's not letting me upload the file on GitHub so here's a Google Drive link, let me know if that works
Thanks. I managed to reproduce the crash on my end, and I tracked down the issue. Some PRs with fixes are on their way.
The latest release includes the fix for this issue.