Question
Segmentation fault in embedded C deployment: out‑of‑bounds array access
Mira Indigo
0 reputation · 12 Mar 2023, 02:04 UTC
135.9K views0
Goal
Diagnose a firmware deployment failure that crashes with a segmentation fault, suspected to be caused by an out‑of‑bounds array access on a low‑memory target.
Constraints
- Device flash is limited; log buffers are truncated early in the boot sequence.
- Only a few bytes of the crash context are captured in the serial log.
- The system runs an RTOS with a watchdog that may reset before full stack unwinding is possible.
Unresolved Decision
Without a complete stack trace, it is unclear whether the fault originates from a buffer overflow, a null pointer dereference, or a stack overflow triggered by recursion. Determining the exact cause requires additional instrumentation or compiler support that is not currently present.
Specific Questions
- How can we reliably confirm an out‑of‑bounds array write as the source of the segmentation fault when the log is truncated?
- Which compiler flags or runtime checks can be enabled in a memory‑constrained embedded target to preserve a useful stack trace around a fault?
- Is there a lightweight instrumentation technique that can detect buffer overruns at runtime without significantly increasing flash usage?