-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assert(0) doesnt cause trap without GDB and breaks execution path #4480
Comments
I'm not seeing any issue or problem with the behavior you're showing here. Maybe you meant to put an assert(1), which will always be true and be compiled into a no-op? |
@earlephilhower I know what you are talking about. but the problem is that assert(0) returns. We've spent a day catching it and can stand for it. Please run the sketch and assure yourself. |
to be clear Arduino/cores/esp8266/core_esp8266_postmortem.c Lines 205 to 215 in a662e81
if |
because it boils down to Arduino/cores/esp8266/core_esp8266_main.cpp Line 143 in 8053f28
|
Got it, I misunderstood the problem you were seeing. And you beat me to the code link by 30 seconds. :) I could swear I saw assertions hang the machine in a prior release, will need to check the relevant histories. I added some code in #4187 which I remember seeing dump the assertion text and halt, because w/o a panic() those stored bits aren't actually dumped to the serial port. Odd. |
@earlephilhower For us, it seems that conditional assertions won't optimize anything from original function, but will also return and cause damage later on, because of the main problem that assertion should trap. But we didnt checked that case for sure yet. |
This seems to be a bug in my original implementation of __assert_func. I'll send a fix. |
Shouldn't we just add an abort() to the end of _assert_func() (esp. since we call is "noreturn")? I can throw the PR in, but not sure now since it seems like you've a different idea... |
Pretty much, yes, plus i also threw in some cleanup. |
With changes in #4482, the reproducer correctly panics:
|
Fixes esp8266#4480 (cherry picked from commit 3b269c4)
setting milestone to 2.4.2 |
Basic Infos
Platform
Settings in IDE
Problem Description
assert(0)
doesn't cause neither trap, nor backtrace, all instructions after that call gets optimized-out, breaking execution logic.Because assert(0) returns, MCU continues code execution with broken logic and can cause fault later on, that is very hard to catch.
MCVE Sketch
Debug Messages
$ xtensa-lx106-elf-objdump.exe -d bug_catcher.ino.elf | sed '/<_Z12changeBufferj>:/,/^$/!d'
The text was updated successfully, but these errors were encountered: