joxeankoret / diaphora

Diaphora, the most advanced Free and Open Source program diffing tool.
http://diaphora.re
GNU Affero General Public License v3.0
3.58k stars 371 forks source link

diaphora crashes (with IDA 7.5) #214

Closed mprevot closed 1 year ago

mprevot commented 3 years ago
C:\Program Files (x86)\IDA Pro 7.5 SP2\plugins\diaphora-plugin\diaphora.py: local variable 'bd' referenced before assignment
Traceback (most recent call last):
  File "C:\Program Files (x86)\IDA Pro 7.5 SP2\python\3\ida_idaapi.py", line 615, in IDAPython_ExecScript
    exec(code, g)
  File "C:/Program Files (x86)/IDA Pro 7.5 SP2/plugins/diaphora-plugin/diaphora.py", line 2154, in <module>
    exec(compile(open(script, "rb").read(), script, 'exec'))
  File "C:/Program Files (x86)/IDA Pro 7.5 SP2/plugins/diaphora-plugin\diaphora_ida.py", line 2635, in <module>
    main()
  File "C:/Program Files (x86)/IDA Pro 7.5 SP2/plugins/diaphora-plugin\diaphora_ida.py", line 2632, in main
    _diff_or_export(True)
  File "C:/Program Files (x86)/IDA Pro 7.5 SP2/plugins/diaphora-plugin\diaphora_ida.py", line 2393, in _diff_or_export
    return bd
UnboundLocalError: local variable 'bd' referenced before assignment

I used today's master diaphora and IDA 7.5 with python 3.9

joxeankoret commented 3 years ago

I have been trying to fix that bug since the first version published in 2015 and it keeps re-appearing from time to time. Thanks for reporting, I will try to fix it again :/

I forgot to say: meanwhile, the workaround is to close IDA and reopen it again.

jpsnyder commented 1 year ago

I noticed this specific UnboundLocalError occurs because it is failing to show the proper traceback.

It is actually erroring out on https://github.com/joxeankoret/diaphora/blob/master/diaphora_ida.py#L2612 because the exception is being caught before it can successfully initialize the CIDABinDiff object at https://github.com/joxeankoret/diaphora/blob/master/diaphora_ida.py#L2560 Therefore the bd variable never gets created.

Adding a raise at the exception catch will show you the true error. (In my case it it was a Database locked error... which I have yet to figure out)

joxeankoret commented 1 year ago

This is bug is finally fixed in Diaphora 3.0, to be released soon. If you want to try the beta please tell me and I will send you it.