pfalcon / ScratchABit

Easily retargetable and hackable interactive disassembler with IDAPython-compatible plugin API
GNU General Public License v3.0
393 stars 47 forks source link

Corrupted database after crashing on save #8

Closed projectgus closed 9 years ago

projectgus commented 9 years ago

While working with ScratchABit I saved my database, during the save (I think) an unhandled exception occurred and scratchabit exited. My database doesn't open any more, the stack trace on opening is:

(Snip many lines of relocation information)
<Relocation (RELA): Container({'r_info_sym': 1, 'r_offset': 7, 'r_addend': 268, 'r_info_type': 11, 'r_info': 267})>
Loading state...
Traceback (most recent call last):
  File "/home/gus/scripts/scratchabit.py", line 587, in <module>
    load_state(project_dir)
  File "/home/gus/scripts/scratchabit.py", line 539, in load_state
    engine.ADDRESS_SPACE.load_funcs(f)
  File "/home/gus/dev/ScratchABit/engine.py", line 487, in load_funcs
    start, end = l.split()
ValueError: need more than 1 value to unpack

I tried renaming the *.bak files over the newer database files, but I get the same error.

Here are the relevant files: http://projectgus.com/misc/esp8266/xtensa_vectors.zip

Working from current git master 74323e9d2c4 and pfalcon/ida-xtensa@cbe43ba3c3b (one commit before current master in your fork).

There's a related bug to the database corruption bug, which is that the stack trace from the unhandled exception on save was printed "inside" ncurses, so it wasn't readable (got interleaved with the UI elements). Also following exit the console mode was set wrong, needed a reset.

Sorry I don't have time to investigate this further right now.

projectgus commented 9 years ago

I triggered the crash again, got a screen capture this time: http://projectgus.com/misc/esp8266/scratchabit_crashonsave.png

Looks like self.func_end[addr] is of type Function, but engine.py:478 expects a number?

pfalcon commented 9 years ago

First of all, code makes a backup of previous files before saving new versions, so hope you didn't lose anything!

(And another good reason to have git integration ;-) ).

pfalcon commented 9 years ago

Should be fixed in https://github.com/pfalcon/ScratchABit/commit/50a4311e572feab90661ebe444c483408732ee65 . But Angus, if you use SAB in "production", do let me know, because otherwise I assume noone does, and I can do an breaking changes without thinking much. And if you use it like that (why not set up public project for it?), the best suggestion I'd have is to use the latest tagged version, currently 0.6. I'm working on robust function detection for 0.7. New YAML-based format for 0.8. And sadly, I don't explicitly have transparent database migration path on roadmap. So, if you expect something like that, let me know, and I'd still need help with that (or, you'd need my hints on how to migrate DB to new version).

projectgus commented 9 years ago

Thanks Paul, appreciate the quick response!

I'm only doing fairly quick/simple bits of investigation on individual object files at the moment, so I'm not dependent on the database staying stable. Happy to live on the "bleeding edge" for now as things develop.

pfalcon commented 9 years ago

Sounds good, thanks for confirming, that's pretty much how I use it too so far, while pumping up features ;-).