SVF-tools / SVF

Static Value-Flow Analysis Framework for Source Code
http://svf-tools.github.io/SVF/
Other
1.4k stars 437 forks source link

Assertion error when running Andersen pointer analysis #179

Open jo285317 opened 4 years ago

jo285317 commented 4 years ago

Tried running: wpa --ander --stat vmlinux.bc Stderr: wpa: /SVF/include/MemoryModel/MemModel.h:571: SymID SymbolTableInfo::getValSym(const Value*): Assertion `iter!=valSymMap.end() &&"value sym not found"' failed.

I obtained the LLVM bit code with wllvm and I'm using llvm-9.

Any suggestions would be appreciated

yuleisui commented 4 years ago

Would you be able to provide the stack trace and the LLVM value which is not found?

If the bc is large, you could also give us a link to download.

jo285317 commented 4 years ago

There is no stack trace, this is the complete output:

nod@xps13:~/linux-5.4.4$ /home/nod/apps/SVF/Release-build/bin/wpa --ander --dump-callgraph vmlinux.bc
wpa: /home/nod/apps/SVF/include/MemoryModel/MemModel.h:571: SymID SymbolTableInfo::getValSym(const Value*): Assertion `iter!=valSymMap.end() &&"value sym not found"' failed.
Aborted (core dumped)

Here is the bc, hosted on google drive

jo285317 commented 4 years ago
Breakpoint 1, SymbolTableInfo::getValSym (this=0x55557f0a8910, val=0x555559084218) at /home/nod/apps/SVF/include/MemoryModel/MemModel.h:571
571             assert(iter!=valSymMap.end() &&"value sym not found");
(gdb) backtrace
#0  SymbolTableInfo::getValSym (this=0x55557f0a8910, val=0x555559084218) at /home/nod/apps/SVF/include/MemoryModel/MemModel.h:571
#1  0x000055555563323b in PAG::getValueNode (this=0x555582c3d400, V=0x555559084218) at /home/nod/apps/SVF/include/MemoryModel/PAG.h:402
#2  0x0000555555737429 in PAGBuilder::initalNode (this=0x7fffffffd9c0) at /home/nod/apps/SVF/lib/MemoryModel/PAGBuilder.cpp:156
#3  0x00005555557369f2 in PAGBuilder::build (this=0x7fffffffd9c0, svfModule=...) at /home/nod/apps/SVF/lib/MemoryModel/PAGBuilder.cpp:48
#4  0x000055555562db2e in PointerAnalysis::initialize (this=0x55557edf0468, svfModule=...) at /home/nod/apps/SVF/lib/MemoryModel/PointerAnalysis.cpp:147
#5  0x0000555555699140 in Andersen::initialize (this=0x55557edf03c0, svfModule=...) at /home/nod/apps/SVF/lib/WPA/Andersen.cpp:99
#6  0x0000555555698ea3 in Andersen::analyze (this=0x55557edf03c0, svfModule=...) at /home/nod/apps/SVF/lib/WPA/Andersen.cpp:71
#7  0x00005555555ffa91 in WPAPass::runPointerAnalysis (this=0x55557252c4b0, svfModule=..., kind=6) at /home/nod/apps/SVF/lib/WPA/WPAPass.cpp:150
#8  0x00005555555ff6f4 in WPAPass::runOnModule (this=0x55557252c4b0, svfModule=...) at /home/nod/apps/SVF/lib/WPA/WPAPass.cpp:101
#9  0x00005555555d58ae in main (argc=4, argv=0x7fffffffddc8) at /home/nod/apps/SVF/tools/WPA/wpa.cpp:50
(gdb) print valSymMap
$1 = {<llvm::DenseMapBase<llvm::DenseMap<llvm::Value const*, unsigned int, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseMapPair<llvm::Value const*, unsigned int> >, llvm::Value const*, unsigned int, llvm::DenseMapInfo<llvm::Value const*>, llvm::detail::DenseMapPair<llvm::Value const*, unsigned int> >> = {<llvm::DebugEpochBase> = {<No data fields>}, <No data fields>}, Buckets = 0x7fffe23a9010, NumEntries = 3797368, NumTombstones = 0, NumBuckets = 8388608}
(gdb) 

Here is a backtrace, along with the value of valSymMap

yuleisui commented 4 years ago

I suspect the value val is not included in the SymMap when collecting symbols. Could you let us know the LLVM value of val?

jo285317 commented 4 years ago

Is this what you need?

(gdb) print *val
$3 = {VTy = 0x5555563e17e0, UseList = 0x55555bbbdb20, SubclassID = 3 '\003', HasValueHandle = 0 '\000', 
  SubclassOptionalData = 0 '\000', SubclassData = 0, NumUserOperands = 1, IsUsedByMD = 0, HasName = 1, 
  HasHungOffUses = 0, HasDescriptor = 0, static MaxAlignmentExponent = 29, 
  static MaximumAlignment = 536870912}
yuleisui commented 4 years ago

can you do "val->dump()"?

jo285317 commented 4 years ago

tried to print val->dump() from gdb. i get: Cannot evaluate function -- may be inlined

shiheyuan commented 4 years ago

I met the same problem when I run wpa --nander vmlinux.bc. The same error log:

wpa: SVF/include/MemoryModel/MemModel.h:571: SymID SymbolTableInfo::getValSym(const Value*): Assertion `iter!=valSymMap.end() &&"value sym not found"' failed.

shiheyuan commented 4 years ago

Tried running: wpa --ander --stat vmlinux.bc Stderr: wpa: /SVF/include/MemoryModel/MemModel.h:571: SymID SymbolTableInfo::getValSym(const Value*): Assertion `iter!=valSymMap.end() &&"value sym not found"' failed.

I obtained the LLVM bit code with wllvm and I'm using llvm-9.

Any suggestions would be appreciated

Hi @jo285317. Do you solve this problem? And can you give me some guidance on how to build kernel by llvm? By the way, I tried to use wllvm(llvm 9.0.0) to build Linux-5.4.6 source, and receive lots of logs like "Failed to find link section for the section XX" in the build procession.

Thanks.

bsauce commented 3 years ago

Is this problem solved? I have the same error too.

yuleisui commented 3 years ago

Yes, solved in the lastest SVF version. Please try and let me know.

bsauce commented 3 years ago

Yes, solved in the lastest SVF version. Please try and let me know.

I installed the newst SVF, but there is another error when I analyzed vmlinux.

john@ubuntu:~/Desktop/test/bitcode$ wpa -indCallLimit=100000 -dump-callgraph -ander -svfg -dump-mssa ./vmlinux.bc > test.txt
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)
yuleisui commented 3 years ago

It looks to me that this is caused by running out of memory on your local machine. How about running Andersen's analysis alone -ander?

bsauce commented 3 years ago

It looks to me that this is caused by running out of memory on your local machine. How about running Andersen's analysis alone -ander?

Yes, you are right. I only have 55G memory. How much memory does it need to analyze a kernel?