Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4127 Segmentation fault "$BIN2LLVMIR" "${BIN2LLVMIR_PARAMS[@]}" -o "$OUT_BACKEND_BC" #373

Closed
kolomparrudi opened this issue Aug 13, 2018 · 4 comments

Comments

@kolomparrudi
Copy link

Hi,

I'm trying to decompile a windows C++ executable and got this error:

Decompiling /root/sample.exe into /root/sample.c.backend.bc...

RUN: /usr/local/bin/retdec-bin2llvmir -provider-init -decoder -verify -main-detection -idioms-libgcc -inst-opt -register -cond-branch-opt -syscalls -stack -constants -param-return -local-vars -inst-opt -simple-types -generate-dsm -remove-asm-instrs -class-hierarchy -select-fncs -unreachable-funcs -inst-opt -value-protect -instcombine -tbaa -targetlibinfo -basicaa -domtree -simplifycfg -domtree -early-cse -lower-expect -targetlibinfo -tbaa -basicaa -globalopt -mem2reg -instcombine -simplifycfg -basiccg -domtree -early-cse -lazy-value-info -jump-threading -correlated-propagation -simplifycfg -instcombine -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa -loop-rotate -licm -lcssa -instcombine -scalar-evolution -loop-simplifycfg -loop-simplify -aa -loop-accesses -loop-load-elim -lcssa -indvars -loop-idiom -loop-deletion -memdep -gvn -memdep -sccp -instcombine -lazy-value-info -jump-threading -correlated-propagation -domtree -memdep -dse -dce -bdce -adce -die -simplifycfg -instcombine -strip-dead-prototypes -globaldce -constmerge -constprop -instnamer -domtree -instcombine -instcombine -tbaa -targetlibinfo -basicaa -domtree -simplifycfg -domtree -early-cse -lower-expect -targetlibinfo -tbaa -basicaa -globalopt -mem2reg -instcombine -simplifycfg -basiccg -domtree -early-cse -lazy-value-info -jump-threading -correlated-propagation -simplifycfg -instcombine -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa -loop-rotate -licm -lcssa -instcombine -scalar-evolution -loop-simplifycfg -loop-simplify -aa -loop-accesses -loop-load-elim -lcssa -indvars -loop-idiom -loop-deletion -memdep -gvn -memdep -sccp -instcombine -lazy-value-info -jump-threading -correlated-propagation -domtree -memdep -dse -dce -bdce -adce -die -simplifycfg -instcombine -strip-dead-prototypes -globaldce -constmerge -constprop -instnamer -domtree -instcombine -simple-types -stack-ptr-op-remove -inst-opt -idioms -global-to-local -dead-global-assign -instcombine -phi2seq -value-protect -disable-inlining -disable-simplify-libcalls -config-path /root/sample.c.json -max-memory-half-ram -o /root/sample.c.backend.bc
Running phase: Initialization ( 0.01s )
Running phase: LLVM ( 0.02s )
Running phase: Providers initialization ( 0.02s )
Running phase: Input binary to LLVM IR decoding ( 0.85s )
/usr/local/bin/retdec-decompiler.sh: line 1264: 4127 Segmentation fault "$BIN2LLVMIR" "${BIN2LLVMIR_PARAMS[@]}" -o "$OUT_BACKEND_BC"
Error: Decompilation to LLVM IR failed

Tried to run from gdb for backtrace:

Running phase: Initialization ( 0.01s )
Running phase: LLVM ( 0.02s )
Running phase: Providers initialization ( 0.02s )
Running phase: Input binary to LLVM IR decoding ( 0.86s )

Program received signal SIGSEGV, Segmentation fault.
0x000055555596d7fb in cs_disasm_iter ()
(gdb) bt
#0 0x000055555596d7fb in cs_disasm_iter ()
#1 0x000055555595370d in retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl<cs_x86, cs_x86_op>::translateOne(unsigned char const*&, unsigned long&, retdec::utils::Address&, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) ()
#2 0x00005555557e71a7 in retdec::bin2llvmir::Decoder::translate(std::pair<unsigned char const*, unsigned long>&, retdec::utils::Address&, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) ()
#3 0x00005555557eb670 in retdec::bin2llvmir::Decoder::decodeJumpTarget(retdec::bin2llvmir::JumpTarget const&) ()
#4 0x00005555557ebd9b in retdec::bin2llvmir::Decoder::decode() ()
#5 0x00005555557ec32d in retdec::bin2llvmir::Decoder::runOnModule(llvm::Module&) ()
#6 0x0000555556216e24 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
#7 0x0000555555788dc0 in _main(int, char**) ()
#8 0x0000555555641aa6 in main ()

@PeterMatula
Copy link
Collaborator

Are you using the current master or pre-built package? It maybe have been fixed in master, but I cannot check it without the input binary. We should release a new version in a few days, so you can try it then.

@kolomparrudi
Copy link
Author

Hi,

Used the latest master. Also tried a windows prebuilt binary with same results. Tried also with IDA plugin, a selective decompile and it worked.

@PeterMatula
Copy link
Collaborator

  1. Can you share the sample? If I was able to reproduce the problem, It would probably be an easy and fast fix.
  2. If not, more precise backtrace could help - build RetDec in debug mode (-DCMAKE_BUILD_TYPE=Debug on linux, --config Debug on Windows) and re-run the gdb. Also, if you are on Linux, send a valgrind log as well.

@PeterMatula
Copy link
Collaborator

PeterMatula commented Mar 2, 2019

Closing the issue, since I cannot reproduce this without a binary or gdb backtrace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants