GrammaTech / ddisasm

A fast and accurate disassembler
https://grammatech.github.io/ddisasm/
GNU Affero General Public License v3.0
645 stars 60 forks source link

[non-pie] fails to disassemble on ubuntu-20.04.6 : process killed #60

Closed gogo2464 closed 1 year ago

gogo2464 commented 1 year ago

ddisasm --version 1.6.0 (cfa30e80 2023-03-21) ARM64+IA32+X64+ARM32+MIPS32

The process is killed. I do not see the asm output yet.

$ ddisasm non-pie --asm PacketTracer.asm Building the initial gtirb representation [ 2s] Processing module: PacketTracer disassembly load Killed

aeflores commented 1 year ago

Hi @gogo2464 Thanks for opening and issue and showing interest in Ddisasm!

We will investigate this case, but my first guess is that the process is running out of RAM. The binary that you pointed out is ~90MB.

Ddisasm is pretty memory intensive. As a rough estimation, any binary over ~20MB is likely going to require more than 32GB of RAM. We are working on lowering the memory consumption to be able to handle bigger, but that will likely take some time.

gogo2464 commented 1 year ago

No problem. I am just setting my computer to use 500GB of swap. If you want I can document on the repo what I did.

Could we just set an option to see percent of adavance on each step?

Thank you very much for your answer.

aeflores commented 1 year ago

I am just setting my computer to use 500GB of swap

I am curious, did it work?

Could we just set an option to see percent of adavance on each step?

Most of the disassembly work is done by the Datalog code (which is transformed to C++ by souffle) so it is not straightforward to record progress there.

gogo2464 commented 1 year ago

"I am curious, did it work?"

Yes :) after 3 days of processing. :) I set up my computer in order to avoid to shutdown automatically.

We might store intermediate calculus into sqlite? What do you think of this idea?

gogo2464 commented 1 year ago

@aeflores I can not recompile it.

ddisasm disassemble with these logs:

Building the initial gtirb representation [    2s]
Processing module: PacketTracer
    disassembly              load [38m44s]    compute 
[ 39h3m]  transform WARNING: Moving symbol to first block of section: __bss_start
[33m19s]
    SCC analysis                              compute [ 2m19s]  transform [   0ms]
    no return analysis       load [ 4m29s]    compute [44m24s]  transform [ 702ms]
    function inference       load [ 7m41s]    compute [ 5m40s]  transform [  1m1s]
Printing assembler [20m24s]

then I did:

I got no error to run it but a segfault and valgrind

==78274== Warning: set address range perms: large range [0x59c97028, 0x7b0b6b1e) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0xa777a75e) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0xa777a776) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0x8c2c8b4c) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0x8c2c8b64) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0xa3c3be9c) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0xa3c3beb4) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0x96975db9) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0x96975dd1) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0x841f69e1) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0x841f69f9) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0xd6ae6274) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0xd6ae628c) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0xd32e56cd) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0xd32e56e5) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0x80a1c76c) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0x80a1c784) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0xb1b11ac9) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0xb1b11ae1) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0x7d952e67) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0x7d952e7f) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0xcb047e39) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0xcb047e51) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0xabec034d) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0xabec0365) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0x7b2303e1) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0x7b2303f9) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0x88187765) (undefined)

==78274== Warning: set address range perms: large range [0x59c97028, 0x8818777d) (noaccess)

==78274== Warning: set address range perms: large range [0x59c97040, 0xb729f014) (undefined)

The original binary is around 90MB

gogo2464 commented 1 year ago

@aeflores do I open an issue?

aeflores commented 1 year ago

Hi @gogo2464 I there is no need to open another issue. Can you clarify, did you manage to reassemble but the rewritten binary crashes? or did the reassembly itself crashed?

Do you have a way of sharing Ddisasm's gtirb file or the assembly output with us?

gogo2464 commented 1 year ago

Yes the binary crashes once recompiled. Can I send you the assembly by email please? I am currently on my phone. I need to wait before sending you the assembly.

gogo2464 commented 1 year ago

@aeflores I sent you an email. Did you received it?

aeflores commented 1 year ago

I did! Unfortunately, it might take me some time to get to it.

gogo2464 commented 1 year ago

@aeflores Ah alright. No problem. Sorry. I will wait.

gogo2464 commented 1 year ago

@aeflores should I ask my question on another canal please?

aeflores commented 1 year ago

As of https://github.com/GrammaTech/ddisasm/commit/2fd73fea0c9641d82528623711f120e2893907de this issue should be solved.