NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
50.5k stars 5.77k forks source link

Limit rendering of Function Graph when number of nodes exceed a limit #3411

Open qrkyckling opened 3 years ago

qrkyckling commented 3 years ago

Describe the bug Hangs on decompiling/Function graph of function main in a certain binary

To Reproduce Load up "01_angr_avoid" from the Angr tutorial in Ghidra 10.0.3 https://github.com/jakespringer/angr_ctf/blob/master/dist/01_angr_avoid

Ghidra hangs for some minutes before throwing an error.

Expected behavior Do not hang

Environment (please complete the following information):

Binary Ninja presents a message like this with a warning about a large function before starting analysis. If press "force analysis" then BN seems to hang as well but at least could have been avoided by not forcing analysis. image

EDIT: BN GUI stays responsive and I can just press Ctrl+Q to exit

dragonmacher commented 3 years ago

The Decompiler is working in the background in this case and does not lockup the UI. On the other hand, the Function Graph is locking the UI while it is building its nodes. The graph is created and laid out in the background, but the nodes are being built in the UI thread. In this case there are over 16000 nodes being built. Each node must access the database, which causes file IO. For a normal graph, this happens in real time or with minimal sluggishness. Assuming the graph were to finish the building process, the graph that gets created would be so large that it would likely make the UI unresponsive when trying to render the graph.

In this case, to work around the issue, the Function Graph should not be open when navigating to this exceptional function. It would be possible for us to add a node limit for graph creation, but no such option currently exists.

qrkyckling commented 3 years ago

Yes. Closing the Function Graph seems to improve the matter a lot.

Actually seems enough to just let a Listing tab stay focused on top of the Function Graph so I guess having the Function Graph anywhere but in the foreground does help. Letting Function Graph complete takes around 5 minutes on my (older) system.

This is not a very common type of binary so I guess I can live with closing the Function Graph. Then perhaps this is better suited as a feature request for not rendering Function Graph for nodes over a certain number ?

dragonmacher commented 3 years ago

Then perhaps this is better suited as a feature request for not rendering Function Graph for nodes over a certain number ?

I think so. We could easily add this with an option to specify a limit for the number of nodes.

qrkyckling commented 3 years ago

Do you prefer I edit this issue into a feature request or close this and create a new one ?

dragonmacher commented 3 years ago

Using this issue is the easiest.