kalibera / rchk

102 stars 10 forks source link

Problems building/running on Gentoo #12

Closed viking closed 5 years ago

viking commented 5 years ago

rchk currently builds on Gentoo Linux using LLVM 4 or 6, but it will segfault when running the check_package.sh script. Here's what happens when built with LLVM 6:

../scripts/check_package.sh: line 77: 19500 Aborted                 $RCHK/src/$T ./src/main/R.bin.bc $F > $FOUT 2>&1

If I rebuild with debugging flags and modify the check_package.sh script to run bcheck with gdb, here's what happens:

$ ../scripts/check_package.sh yaml
GNU gdb (Gentoo 8.1 p1) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/viking/Packages/rchk/src/bcheck...done.
(gdb) run ./src/main/R.bin.bc packages/lib/yaml/libs/yaml.so.bc
Starting program: /home/viking/Packages/rchk/src/bcheck ./src/main/R.bin.bc packages/lib/yaml/libs/yaml.so.bc
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
bcheck: /usr/lib64/llvm/6/include/llvm/IR/CallSite.h:187: ValTy* llvm::CallSiteBase<FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy>::getArgument(unsigned int) const [with FunTy = llvm::Function; BBTy = llvm::BasicBlock; ValTy = llvm::Value; UserTy = llvm::User; UseTy = llvm::Use; InstrTy = llvm::Instruction; CallTy = llvm::CallInst; InvokeTy = llvm::InvokeInst; IterTy = llvm::Use*]: Assertion `arg_begin() + ArgNo < arg_end() && "Argument # out of range!"' failed.

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      }
(gdb) where
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007fffeac82ae7 in __GI_abort () at abort.c:90
#2  0x00007fffeac788ea in __assert_fail_base (
    fmt=0x7fffeadd8d20 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x5555555f8be0 "arg_begin() + ArgNo < arg_end() && \"Argument # out of range!\"", file=file@entry=0x5555555f8ba8 "/usr/lib64/llvm/6/include/llvm/IR/CallSite.h", 
    line=line@entry=187, 
    function=function@entry=0x5555555f9a60 <llvm::CallSiteBase<llvm::Function, llvm::BasicBlock, llvm::Value, llvm::User, llvm::Use, llvm::Instruction, llvm::CallInst, llvm::InvokeInst, llvm::Use*>::getArgument(unsigned int) const::__PRETTY_FUNCTION__> "ValTy* llvm::CallSiteBase<FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy>::getArgument(unsigned int) const [with FunTy = llvm::Function; BBTy = llvm::BasicBlock; ValTy = llvm::Va"...) at assert.c:92
#3  0x00007fffeac78972 in __GI___assert_fail (
    assertion=0x5555555f8be0 "arg_begin() + ArgNo < arg_end() && \"Argument # out of range!\"", 
    file=0x5555555f8ba8 "/usr/lib64/llvm/6/include/llvm/IR/CallSite.h", line=187, 
    function=0x5555555f9a60 <llvm::CallSiteBase<llvm::Function, llvm::BasicBlock, llvm::Value, llvm::User, llvm::Use, llvm::Instruction, llvm::CallInst, llvm::InvokeInst, llvm::Use*>::getArgument(unsigned int) const::__PRETTY_FUNCTION__> "ValTy* llvm::CallSiteBase<FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy>::getArgument(unsigned int) const [with FunTy = llvm::Function; BBTy = llvm::BasicBlock; ValTy = llvm::Va"...) at assert.c:101
#4  0x0000555555561307 in llvm::CallSiteBase<llvm::Function, llvm::BasicBlock, llvm::Value, llvm::User, llvm::Use, llvm::Instruction, llvm::CallInst, llvm::InvokeInst, llvm::Use*>::getArgument (
    this=0x7fffffffc6e8, ArgNo=0) at /usr/lib64/llvm/6/include/llvm/IR/CallSite.h:187
#5  0x000055555558f4cf in SEXPGuardsChecker::handleForTerminator (this=0x55555e4be710, 
    t=0x555556b8fb88, s=...) at guards.cpp:851
#6  0x000055555559f4e4 in getCalledAndWrappedFunctions (f=0x55555cdd6a08, msg=..., 
    called=std::set with 4 elements = {...}, wrapped=std::set with 0 elements)
    at callocators.cpp:738
#7  0x00005555555a0307 in CalledModuleTy::computeCalledAllocators (this=0x7fffffffd1e0)
    at callocators.cpp:855
#8  0x000055555555ca28 in CalledModuleTy::getContextSensitiveAllocatingFunctions (
    this=0x7fffffffd1e0) at callocators.h:176
#9  0x000055555555aa5f in main (argc=3, argv=0x7fffffffd748) at bcheck.cpp:535

Let me know what further information I can provide to help.

kalibera commented 5 years ago

Thanks a lot for the report. I think it is a missing bounds check, could you please try again with 4ab9e71 (or newer)? Thanks!

viking commented 5 years ago

I rebuilt with the latest version, and it worked! I'm happy to be able to run rchk natively instead of relying on the VM. Thanks!

kalibera commented 5 years ago

I am happy it's working, thanks again for the report and stacktrace!