panda-re / panda

Platform for Architecture-Neutral Dynamic Analysis
https://panda.re
Other
2.45k stars 475 forks source link

Fix start_block_exec nondeterminism #1471

Open lacraig2 opened 5 months ago

lacraig2 commented 5 months ago

1447 determined that switching callstack_instr to start_block_exec caused nondeterministic behavior.

This PR attempts to resolve that issue.

AndrewFasano commented 5 months ago

Prior to this, if panda_exit_loop was true was the sequence of events something like: 1) An interrupt/exception/etc occurs which should redirect control flow from block B (about to be executed) to block C (some other place) 2) SBE callback triggers for block B 3) SBE callback triggers for block C 4) Code in block C runs (probably multiple blocks with SBE/EBE callbacks firing as exepected) 5) Control flow returns to block B 6) SBE callback triggers again for block B 7) Block B actually runs

And the issue was that this double-SBE callback for block B should have only happened once (and was non-deterministic in when it happened twice)

AndrewFasano commented 5 months ago

Even if this doesn't fix the issue in #1447, is this still worth merging? Or do you want to try tracking it down further and seeing if you find the fix?

lacraig2 commented 5 months ago

I'm not sure it really adds anything in the scenario that it doesn't fix #1447.

Or rather, I expect this and something else will completely resolve #1447, but I haven't had a chance to figure out what that is.