Debugging a deadlock/hang

Posts: 15
Joined: Wed May 02, 2018 4:26 pm

Debugging a deadlock/hang

Postby jens.alfke » Thu Jun 28, 2018 4:32 pm

My app will sometimes just freeze -- it stops logging and responding to network requests. I'd like to interrupt it and drop into the GDB stub and look at the thread/task stacks. Is there a way to do this? I can't find a monitor command for it.

My dev board (a SparkFun ESP32 Thing) has two physical buttons, but one just restarts the app and the other does nothing. Maybe there's a way to hook up the second button to raise an NMI whose handler will drop into the GDB stub?

(I know about the task watchdog; it isn't triggering. I suspect what I have is a deadlock, not an infinite loop.)

Posts: 494
Joined: Fri Jan 12, 2018 9:10 pm

Re: Debugging a deadlock/hang

Postby mikemoy » Thu Jun 28, 2018 4:46 pm

Just FYI, The other does not do anything, it's used to manually put it into programming mode.
it stops logging and responding to network requests.
printf, is one of your greatest helpers.
Just create another task that spits something like the time to the serial port every second.
If that stops working then you know you have bigger issues.

Start slapping them into your networking task as well, to see where the "hang / lockup" is.
Start spitting out your uxTaskGetStackHighWaterMark, to see if your running out of memory for your task.

Posts: 37
Joined: Fri Feb 16, 2018 7:06 pm

Re: Debugging a deadlock/hang

Postby Pibbotley » Fri Jun 29, 2018 3:55 pm

Memory problems tend to cause crashes rather than hangs. I once had an annoying hang from corruption by a buffer overflow due to my sloppy coding.

Who is online

Users browsing this forum: No registered users and 50 guests