embedded
runtime_error
ai_generated
partial
HardFault_Handler: FORCED, bus fault at address 0x00000000
ID: embedded/hardfault-handler
55%Fix Rate
85%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 32 | active | — | — | — |
Root Cause
ARM Cortex-M hard fault. Null pointer, stack overflow, unaligned access, or invalid memory.
genericWorkarounds
-
85% success Read stacked PC/LR from exception frame to find faulting instruction
In handler: read SP, stacked_pc = *(SP+24), look up in .map file
-
88% success Enable BusFault, MemManage, UsageFault handlers for specific info
SCB->SHCSR |= (BUSFAULTENA | MEMFAULTENA | USGFAULTENA);
-
80% success Check stack size and add overflow detection
FreeRTOS: configCHECK_FOR_STACK_OVERFLOW=2; Bare metal: fill stack with 0xDEADBEEF
Dead Ends
Common approaches that don't work:
-
Add while(1) in HardFault handler and inspect PC in debugger
72% fail
PC in handler points to handler itself, not faulting instruction. Read stacked PC from exception frame.
-
Increase heap size assuming memory allocation failure
78% fail
Hard faults are usually stack overflow or dangling pointers. Heap failures return NULL.
-
Disable fault handlers to prevent stopping
92% fail
Without handlers, faults escalate to lockup; processor halts until hardware reset