AnsweredAssumed Answered

Why are these bugs occuring in GCC, but not mbed's online compiler?

Question asked by mccarthy.matt on Jan 2, 2015
Latest reply on Jan 20, 2015 by Jacobs.Carl.001
We've recently switched toolchains from mbed's online compiler to gcc-arm, but had several issues after doing so. Our code, which works fine when compiled online, seems to have issues once we use gcc to compile.

Execution appears to end abruptly at certain points, so we stepped through the code using gdb, and noticed that HardFault_Handler() keeps getting called just before things stop working. In an attempt to avoid stack corruption and null references, we made some of our variables static, which allowed us to progress further through the code without issue.

However, making all of our variables static is clearly not the most appropriate way to go about this, since we didn't have these problems when compiling through mbed. We have verified that we don't have buffer overflows or array-bounds issues. Could it be something more nuanced with gcc that could be causing issues (e.g., stack reuse) with these variables?

Additionally, this problem seems to only happen after context switches in mbed-rtos. Has anyone else had problems with registers be restored improperly?