Use libasan to catch a Stack over flow bug #62203
Replies: 1 comment
|
The trap in For this class of bug I would first switch from “catch the fatal error” to “watch the guard word”. On
ASan does not always help here because Zephyr is managing thread stacks itself, and the compiler stack protector check fires after the overwrite has already happened. If the bad write is through a normal instrumented object, ASan may catch it; if it is just a task stack growing into the sentinel, the RTOS check is the thing that detects it. A few practical narrowing steps: CONFIG_NO_OPTIMIZATIONS=y
CONFIG_INIT_STACKS=y
CONFIG_THREAD_STACK_INFO=y
CONFIG_STACK_SENTINEL=y
CONFIG_STACK_USAGE=yThen increase stacks one thread at a time. If increasing only one test thread makes the failure disappear, inspect that thread's deepest call path and generate compiler stack-usage files ( So the highest-signal path is: use the Zephyr fatal log to identify the damaged stack, use gdb watchpoints to catch the first write to the sentinel, then use |
Uh oh!
There was an error while loading. Please reload this page.
Hello Zephyr Team,
I'm trying to use
CONFIG_STACK_CANARIES=ywith ztest on Zephyr v2.7.1 (Board=native_posix), the problem is in one of my unit tests i get OS CrashThe unit tests started with the following args:
tests
prj.conf:How can i know the source of the problem ? libasan didn't catch it, unless I raise a trap signal in the fault handler:
but that also didn't help that much
Without
CONFIG_STACK_CANARIEStests run smoothly without any problem, but that looks to me as if the problem is hidden until it bites back in the future.What are some suggestions to help me catch the source of the bug ?
Thanks in advance :)
All reactions