Crash compiling atomics code
Closed this issue · 1 comments
brooksdavis commented
Reduce test cast and args:
https://gist.github.com/brooksdavis/632dc9f3435a1515b328af482ad2dfb8
Crash:
$ ~/cheri/build/llvm-project-build/bin/clang -o /dev/null -c --target=riscv64-unknown-freebsd14.0 -march=rv64gcxcheri -mabi=l64pc128d -mno-relax /tmp/atomic-8e0e22-pp-smaller-reduce.c /tmp/atomic-8e0e22-pp-smaller-reduce.c:2:43: warning: incompatible pointer to integer conversion passing 'void ()' to parameter of type 'long' [-Wint-conversion]
void b() { __atomic_sub_fetch((void **)a, b, 5); } ^
/tmp/atomic-8e0e22-pp-smaller-reduce.c:2:12: warning: unsupported atomic operation may incur significant performance penalty [-Watomic-alignment]
void b() { __atomic_sub_fetch((void **)a, b, 5); }
^
Assertion failed: (getType()->isIntOrIntVectorTy() && "Tried to create an integer operation on a non-integer type!"), function AssertOK, file /home/bed22/cheri/llvm-proj
ect/llvm/lib/IR/Instructions.cpp, line 2517.
#0 0x000000000386e84a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x386e84a)
#1 0x000000000386ec78 __assert (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x386ec78)
#2 0x000000000310e51e llvm::BinaryOperator::AssertOK() (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x310e51e)
#3 0x000000000310e957 llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x310e957)
#4 0x00000000027ef471 llvm::IRBuilderBase::CreateBinOp(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::MDNode*) X86InstCombineIntrinsic.cpp:0:0
#5 0x0000000003d9dbab clang::CodeGen::CodeGenFunction::EmitAtomicExpr(clang::AtomicExpr*)(/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3d9dbab)
#6 0x0000000003bbc859 (anonymous namespace)::ScalarExprEmitter::VisitAtomicExpr(clang::AtomicExpr*) CGExprScalar.cpp:0:0 #7 0x0000000003bad03b clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3bad03b)
#8 0x0000000003b83128 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b83128)
#9 0x0000000003b830c9 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*)(/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b830c9)
#10 0x0000000003be7db0 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3be7db0)
#11 0x0000000003bf3571 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3bf3571)
#12 0x0000000003bd8832 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3bd8832)
#13 0x0000000003bd9417 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3bd9417)
#14 0x0000000003b1c2a6 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b1c2a6)
#15 0x0000000003b14a18 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b14a18)
#16 0x0000000003b18ea0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b18ea0)
#17 0x0000000003b20303 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b20303)
#18 0x00000000043ea780 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#19 0x00000000043e7de5 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) CodeGenAction.cpp:0:0
#20 0x0000000004bf0ae7 clang::ParseAST(clang::Sema&, bool, bool) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x4bf0ae7)
#21 0x0000000004323493 clang::FrontendAction::Execute() (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x4323493)
#22 0x00000000042a474f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x42a474f)
#23 0x00000000043e16f6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x43e16f6)
#24 0x0000000001f9d0da cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x1f9d0da) #25 0x0000000001f9a877 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#26 0x0000000004163b27 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const::$_1>(long) Job.cpp:0:0 #27 0x00000000037e5440 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x37e5440)
#28 0x000000000416363b clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x416363b)
#29 0x0000000004133405 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x4133405)
#30 0x0000000004133839 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) const (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x4133839)
#31 0x00000000041482cc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x41482cc)
PLEASE submit a bug report to https://github.com/CTSRD-CHERI/llvm-project/issues and include the crash backtrace, preprocessed source, and associated run script.
If you built clang from source, please provide a reduced test case by running:
$LLVM_BUILD_DIR/bin/creduce_crash_testcase.py <reproducer>.sh
Stack dump:
0. Program arguments: /home/bed22/cheri/build/llvm-project-build/bin/clang -o /dev/null -c --target=riscv64-unknown-freebsd14.0 -march=rv64gcxcheri -mabi=l64pc128d
-mno-relax /tmp/atomic-8e0e22-pp-smaller-reduce.c
1. <eof> parser at end of file
3. /tmp/atomic-8e0e22-pp-smaller-reduce.c:2:6: LLVM IR generation of declaration 'b'
4. /tmp/atomic-8e0e22-pp-smaller-reduce.c:2:6: Generating code for declaration 'b'
#0 0x000000000386e84a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x386e84a)
#1 0x000000000386c728 llvm::sys::RunSignalHandlers() (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x386c728)
#2 0x00000000037e5524 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
#3 0x00000000037e56e0 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x000000080644b580 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
#5 0x000000080644ab3f thr_sighandler /usr/src/lib/libthr/thread/thr_sig.c:247:1
#6 0x00007ffffffff8a3 ([vdso]+0x2d3)
#7 0x000000080676933a thr_kill /usr/obj/usr/src/amd64.amd64/lib/libc/thr_kill.S:4:0
#8 0x00000008066e1c74 _raise /usr/src/lib/libc/gen/raise.c:0:10
#9 0x0000000806793109 abort /usr/src/lib/libc/stdlib/abort.c:73:17
#10 0x000000000386ec7d (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x386ec7d)
#11 0x000000000310e51e llvm::BinaryOperator::AssertOK() (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x310e51e)
#12 0x000000000310e957 llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x310e957)
#13 0x00000000027ef471 llvm::IRBuilderBase::CreateBinOp(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::MDNode*) X86InstCombineIntrinsic.cpp:0:0
#14 0x0000000003d9dbab clang::CodeGen::CodeGenFunction::EmitAtomicExpr(clang::AtomicExpr*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3d9dbab)
#15 0x0000000003bbc859 (anonymous namespace)::ScalarExprEmitter::VisitAtomicExpr(clang::AtomicExpr*) CGExprScalar.cpp:0:0
#16 0x0000000003bad03b clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3bad03b)
#17 0x0000000003b83128 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b83128)
#18 0x0000000003b830c9 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b830c9)
#19 0x0000000003be7db0 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3be7db0)
#20 0x0000000003bf3571 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3bf3571)
#21 0x0000000003bd8832 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3bd8832)
#22 0x0000000003bd9417 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3bd9417)
#23 0x0000000003b1c2a6 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b1c2a6)
#24 0x0000000003b14a18 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b14a18)
#25 0x0000000003b18ea0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b18ea0)
#26 0x0000000003b20303 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x3b20303)
#27 0x00000000043ea780 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#28 0x00000000043e7de5 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) CodeGenAction.cpp:0:0
#29 0x0000000004bf0ae7 clang::ParseAST(clang::Sema&, bool, bool) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x4bf0ae7)
#30 0x0000000004323493 clang::FrontendAction::Execute() (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x4323493)
#31 0x00000000042a474f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x42a474f)
#32 0x00000000043e16f6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x43e16f6)
#33 0x0000000001f9d0da cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x1f9d0da)
#34 0x0000000001f9a877 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#35 0x0000000004163b27 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const::$_1>(long) Job.cpp:0:0
#36 0x00000000037e5440 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x37e5440)
#37 0x000000000416363b clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x416363b)
#38 0x0000000004133405 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x4133405)
#39 0x0000000004133839 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) const (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x4133839)
#40 0x00000000041482cc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) (/home/bed22/cheri/build/llvm-project-build/bin/clang+0x41482cc)
clang-13: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 13.0.0 (git@github.com:CTSRD-CHERI/llvm-project.git a2d63848a693e9c64b2edd3ec8194733bc0bc0e2)
Target: riscv64-unknown-freebsd14.0
Thread model: posix
InstalledDir: /home/bed22/cheri/build/llvm-project-build/bin
clang-13: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/atomic-8e0e22-pp-smaller-reduce-a33f98.c
clang-13: note: diagnostic msg: /tmp/atomic-8e0e22-pp-smaller-reduce-a33f98.sh
clang-13: note: diagnostic msg:
********************
brooksdavis commented
The code at fault seems to be the atomic add/sub code in CheriBSD's sys/contrib/openzfs/lib/libspl/atomic.c