Crash building RISC-V hybrid sys/netlink/route.c
bsdjhb opened this issue · 5 comments
===> netlink (all)
/home/john/work/cheri/output/sdk/bin/clang -target riscv64-unknown-freebsd14.0 --sysroot=/usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/tmp -B/usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/tmp/usr/bin -O2 -pipe -fno-common -march=rv64imafdcxcheri -mabi=lp64d -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -DKLD_TIED -nostdinc -DHAVE_KERNEL_OPTION_HEADERS -include /usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/sys/CHERI-QEMU/opt_global.h -I. -I/usr/home/john/work/cheri/git/cheribsd/sys -I/usr/home/john/work/cheri/git/cheribsd/sys/contrib/ck/include -fno-common -g -fPIC -fdebug-prefix-map=./machine=/usr/home/john/work/cheri/git/cheribsd/sys/riscv/include -I/usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/sys/CHERI-QEMU -MD -MF.depend.route_route.o -MTroute/route.o -march=rv64imafdcxcheri -mabi=lp64 -mno-relax -ffreestanding -fwrapv -fstack-protector -Wall -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-format-zero-length -mcmodel=medium -std=iso9899:1999 -c /usr/home/john/work/cheri/git/cheribsd/sys/netlink/route/route.c -o route/route.o
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/john/work/cheri/output/sdk/bin/clang -target riscv64-unknown-freebsd14.0 --sysroot=/usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/tmp -B/usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/tmp/usr/bin -O2 -pipe -fno-common -march=rv64imafdcxcheri -mabi=lp64d -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -DKLD_TIED -nostdinc -DHAVE_KERNEL_OPTION_HEADERS -include /usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/sys/CHERI-QEMU/opt_global.h -I. -I/usr/home/john/work/cheri/git/cheribsd/sys -I/usr/home/john/work/cheri/git/cheribsd/sys/contrib/ck/include -fno-common -g -fPIC -fdebug-prefix-map=./machine=/usr/home/john/work/cheri/git/cheribsd/sys/riscv/include -I/usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/sys/CHERI-QEMU -MD -MF.depend.route_route.o -MTroute/route.o -march=rv64imafdcxcheri -mabi=lp64 -mno-relax -ffreestanding -fwrapv -fstack-protector -Wall -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-format-zero-length -mcmodel=medium -std=iso9899:1999 -c /usr/home/john/work/cheri/git/cheribsd/sys/netlink/route/route.c -o route/route.o
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '/usr/home/john/work/cheri/git/cheribsd/sys/netlink/route/route.c'.
4. Running pass 'Loop Pass Manager' on function '@nlattr_get_multipath'
5. Running pass 'Loop Strength Reduction' on basic block '%for.body.i.preheader'
#0 0x000000000381b8f7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/john/work/cheri/output/sdk/bin/clang+0x381b8f7)
#1 0x00000000038197f8 llvm::sys::RunSignalHandlers() (/home/john/work/cheri/output/sdk/bin/clang+0x38197f8)
#2 0x0000000003791214 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
#3 0x00000000037913d0 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x0000000827c65a60 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
#5 0x0000000827c6501f thr_sighandler /usr/src/lib/libthr/thread/thr_sig.c:247:1
#6 0x00007ffffffff2d3 ([vdso]+0x2d3)
#7 0x0000000003645a25 ReduceLoopStrength(llvm::Loop*, llvm::IVUsers&, llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::MemorySSA*) LoopStrengthReduce.cpp:0:0
#8 0x0000000003671ccf (anonymous namespace)::LoopStrengthReduce::runOnLoop(llvm::Loop*, llvm::LPPassManager&) LoopStrengthReduce.cpp:0:0
#9 0x00000000029d43b0 llvm::LPPassManager::runOnFunction(llvm::Function&) (/home/john/work/cheri/output/sdk/bin/clang+0x29d43b0)
#10 0x00000000031136d7 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/john/work/cheri/output/sdk/bin/clang+0x31136d7)
#11 0x000000000311b921 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/john/work/cheri/output/sdk/bin/clang+0x311b921)
#12 0x00000000031140e6 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/john/work/cheri/output/sdk/bin/clang+0x31140e6)
#13 0x0000000003f14a9f (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#14 0x0000000003f0f951 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) (/home/john/work/cheri/output/sdk/bin/clang+0x3f0f951)
#15 0x0000000004372e37 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#16 0x0000000004b5cae4 clang::ParseAST(clang::Sema&, bool, bool) (/home/john/work/cheri/output/sdk/bin/clang+0x4b5cae4)
#17 0x00000000042a4083 clang::FrontendAction::Execute() (/home/john/work/cheri/output/sdk/bin/clang+0x42a4083)
#18 0x000000000422689f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/john/work/cheri/output/sdk/bin/clang+0x422689f)
#19 0x000000000436c37a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/john/work/cheri/output/sdk/bin/clang+0x436c37a)
#20 0x0000000001fe485a cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/john/work/cheri/output/sdk/bin/clang+0x1fe485a)
#21 0x0000000001fe2147 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#22 0x00000000040e7b17 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
#23 0x0000000003791130 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/john/work/cheri/output/sdk/bin/clang+0x3791130)
#24 0x00000000040e762b 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/john/work/cheri/output/sdk/bin/clang+0x40e762b)
#25 0x00000000040b7665 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/john/work/cheri/output/sdk/bin/clang+0x40b7665)
#26 0x00000000040b7a99 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) const (/home/john/work/cheri/output/sdk/bin/clang+0x40b7a99)
#27 0x00000000040cc17c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) (/home/john/work/cheri/output/sdk/bin/clang+0x40cc17c)
clang-13: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 13.0.0 (git@github.com:CTSRD-CHERI/llvm-project.git f06202e95b8ba0ca0655ab5753f0fff070007e1f)
Target: riscv64-unknown-freebsd14.0
Thread model: posix
InstalledDir: /home/john/work/cheri/output/sdk/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/route-fdaa28.c
clang-13: note: diagnostic msg: /tmp/route-fdaa28.sh
clang-13: note: diagnostic msg:
********************
*** Failed target: route/route.o
*** Failed command: /home/john/work/cheri/output/sdk/bin/clang -target riscv64-unknown-freebsd14.0 --sysroot=/usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/tmp -B/usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/tmp/usr/bin -O2 -pipe -fno-common -march=rv64imafdcxcheri -mabi=lp64d -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -DKLD_TIED -nostdinc -DHAVE_KERNEL_OPTION_HEADERS -include /usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/sys/CHERI-QEMU/opt_global.h -I. -I/usr/home/john/work/cheri/git/cheribsd/sys -I/usr/home/john/work/cheri/git/cheribsd/sys/contrib/ck/include -fno-common -g -fPIC -fdebug-prefix-map=./machine=/usr/home/john/work/cheri/git/cheribsd/sys/riscv/include -I/usr/obj/cheri/cheribsd-riscv64-purecap-build/usr/home/john/work/cheri/git/cheribsd/riscv.riscv64c/sys/CHERI-QEMU -MD -MF.depend.route_route.o -MTroute/route.o -march=rv64imafdcxcheri -mabi=lp64 -mno-relax -ffreestanding -fwrapv -fstack-protector -Wall -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-format-zero-length -mcmodel=medium -std=iso9899:1999 -c /usr/home/john/work/cheri/git/cheribsd/sys/netlink/route/route.c -o route/route.o
*** Error code 139
Trying to use creduce_crash_testcase.py wasn't very useful as it didn't find a crash message. It looks more like a NULL pointer dereference or the like in ReduceLoopStrength. The line information isn't useful though for that frame (0:0).
Result from the testcase script: route-fdaa28-bugpoint-reduce.test.ll.txt
(gdb) x/i 0x0000000003645a25
0x3645a25 <ReduceLoopStrength(llvm::Loop*, llvm::IVUsers&, llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::MemorySSA*)+565>: mov (%rax),%rsi
No line info though as I guess the default cheribuild of LLVM doesn't include debug symbols.
:( I wish llvm-reduce would not introduce undef everywhere to make the testcase somewhat useless. I believe that may have been fixed upstream but we still need merge those commits.
Pre-processed source: route-fdaa28.c.txt
This is fixed in the LLVM 14 update branch. Likely fixes could be the reland of https://reviews.llvm.org/D105207 where we have a previous version that was reverted due to crashes in the current dev branch. Or maybe 2537120