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.

@digitalentity
Copy link
Copy Markdown
Author

The TestBuild test is flaky - I've seen it failing randomly even locally.

- 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 217664b to 3d78ac8 Compare May 16, 2026 09:06
@deadprogram deadprogram requested a review from aykevl May 17, 2026 05:57
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