Skip to content

runtime: improve hardfault handler and stack reporting on Cortex-M#5380

Open
digitalentity wants to merge 1 commit into
tinygo-org:devfrom
helvionics:de_better_hardfault_handler
Open

runtime: improve hardfault handler and stack reporting on Cortex-M#5380
digitalentity wants to merge 1 commit into
tinygo-org:devfrom
helvionics:de_better_hardfault_handler

Conversation

@digitalentity
Copy link
Copy Markdown

Add reference to the current goroutine stack (PSP) when showing the hardfault info on Cortex-M. The stack where the hardfault happens is usually the scheduler's stack (MSP), which provides no information about the goroutine that actually caused the fault.

This was required to debug random crashes (#5375). The reason was stack overflow, which trigered the udf instruction. The MSP only pointed to the HardFault handler and the PC initially suggested stack corruption and nil dereference, while in reality the stack canary was overwritten which triggered a panic.

- Add reference to the current goroutine stack (PSP) when showing the hardfault info on Cortex-M.
@digitalentity digitalentity force-pushed the de_better_hardfault_handler branch from 63dc7f7 to 217664b Compare May 10, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant