mbed locks up, how do I find out what is causing it?

15 Jun 2012

I have a massive data structure (stored on sd card) that is managed via tcp network messages. I have found an exact set of steps to reproduce the problem, and have used printf("%d\n", LINE) style debugging to figure out where it happens.

The problem is that the mbed locks up with an fopen() call. No further response is given to tcp connections, and no further progress is shown with the printf() lines.

How do I determine which of the following is my problem?

1. corrupted the heap? 2. overrun the stack? 3. found a libc bug? 4. networking vs. sd overruning shared memory buffers? 5. other networking or sd bug?

Any hints on how to tell the difference?

I have some ideas, but also looking for suggestions from the community.

Thanks.

15 Jun 2012

Is the code which reproduces this problem something that you could share? If so, I might be able to make some mods that would help extract some more useful debugging information out of the program when it gets into this state. If you think this could be helpful, send me a link to your code and also let me know which OS you are running so that I can point you to the correct place to get GDB.

You might also want to try adding this to your main source file to print out a message if it happens to be caused by a hard fault.

extern "C" void HardFault_Handler()
{
    error("Hit HardFault handler!\n");
}