STM32F105 Stack Overflow in Eclipse Debug mode
Posted: Fri Nov 22, 2013 6:32 pm
Dear all,
I am using ChibiOS to develop a Real-Time OS based autopilot for UAVs (https://github.com/paparazzi/paparazzi/ ... _paparazzi) and I ran into a subtle problem.
My applications has 9 threads, each thread has enough allocated stack size (at least 256kb). If I just flast the code and run it, it works great with no problem. However, when I launch the code in debug mode from Eclipse debugger, I seemingly randomly get "stack overflow error" at either chCreateStatic() or chThdSleepUntil() at the very beginning of the program. This error happens approximately every second time I try to start debug session.
However, if I step over the code the stack overflow doesn't happen.
I am calling chCreateStatic() for all threads from the main thread, so I tried to increase stack size for each thread (no effect) and for the main stack in the linker script (also no effect). Decreasing(!) the stack size on the other hand causes _unhandled_exception instead of stack overflow (as I would expect to happen every time with inssufficient stack size).
I read abou similar issue in viewtopic.php?f=16&t=1106 and viewtopic.php?f=2&t=714
Could you please point me to what might cause the problem? Might it be the debugger issue (since the program runs seemingly without problems if not in debug mode)?
I have all the debug checks in chconf.h enabled. I am using Eclipse Kepler Service Release 1 (build id 20130919-0819) with GDB debugger version 7.2.0 and ChibiOS v 2.6.2 and arm-none-eabi toolchain version 4.7.4 20130913
Thank you very much.
Michal
I am using ChibiOS to develop a Real-Time OS based autopilot for UAVs (https://github.com/paparazzi/paparazzi/ ... _paparazzi) and I ran into a subtle problem.
My applications has 9 threads, each thread has enough allocated stack size (at least 256kb). If I just flast the code and run it, it works great with no problem. However, when I launch the code in debug mode from Eclipse debugger, I seemingly randomly get "stack overflow error" at either chCreateStatic() or chThdSleepUntil() at the very beginning of the program. This error happens approximately every second time I try to start debug session.
However, if I step over the code the stack overflow doesn't happen.
I am calling chCreateStatic() for all threads from the main thread, so I tried to increase stack size for each thread (no effect) and for the main stack in the linker script (also no effect). Decreasing(!) the stack size on the other hand causes _unhandled_exception instead of stack overflow (as I would expect to happen every time with inssufficient stack size).
I read abou similar issue in viewtopic.php?f=16&t=1106 and viewtopic.php?f=2&t=714
Could you please point me to what might cause the problem? Might it be the debugger issue (since the program runs seemingly without problems if not in debug mode)?
I have all the debug checks in chconf.h enabled. I am using Eclipse Kepler Service Release 1 (build id 20130919-0819) with GDB debugger version 7.2.0 and ChibiOS v 2.6.2 and arm-none-eabi toolchain version 4.7.4 20130913
Thank you very much.
Michal