Hardfault on boot, caused by code that is never run

I’m scratching my head hoping for some suggestions to try. While developing an application for RIOT, all the sudden the system quit booting. I isolated the problem to the CPU hard faulting on boot. I can set a breakpoint on kernel_init and see that it runs. I never hit the breakpoint I have set on main. I tried stepping though the code in gdb, but it seems to get lost at some point in creating and running the main thread.

I isolated the code in my application that triggered the problem to a single line of code (a function call). That line is called from main, which is never reached. I can add a second call to the function after the first and the problem goes away.

I tried updating RIOT, and the problem also goes away. git bisect shows the commit 0b52b3e62e93075bc6c8fba369cde8636c04e524 is the commit that fixed the problem (here is the related PR). I’ve further tracked the exact fix to this one. Further supporting this, with versions of RIOT prior to the fix, I can add -DNDEBUG or -DDEBUG_ASSERT_VERBOSE to my CFLAGS and the problem goes away.

What could be going on here? Since the intent of the PR was not to fix any bugs, I’m not certain if the problem is really fixed or just obscured again. Looking for ideas of what I could test next. I’m using a stm32f4discovery eval board.

1 Like