blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.22k stars 767 forks source link

Unable to recover from loss-of-target without `abort()` #1836

Closed xobs closed 1 month ago

xobs commented 4 months ago

It is not possible to recover from the loss of a target.

When a target is lost, an exception is raised. The target list is then freed:

https://github.com/blackmagic-debug/blackmagic/blob/e4da644bb8c0c81498a0f3819bbd99fd6627cd8e/src/main.c#L87-L92

The problem comes from the fact that target_list_free() is not contained within a try {} block. If there is still a target attached it will attempt to do various things such as resetting breakpoints on the target which no longer exists which will raise another exception and cause a reboot.

dragonmux commented 1 month ago

After #1851 was merged to main, this should have been resolved we believe - could you please test again and let us know if it is or not?

xobs commented 1 month ago

I've finally managed to test this, and it does indeed work now. Thanks for the fix!