Skip to content

Conversation

@niaow
Copy link
Member

@niaow niaow commented Dec 5, 2025

The setjmp code sets r24 to 0 and checks if it is still 0 when it finishes. This usually works because tinygo_longjmp stores the lower half of the stack pointer into r24. However, r24 will be set to 0 if the stack is aligned to 256 bytes when entering the setjmp.

Manually set r24 to 1 in tinygo_longjmp to fix this issue.

…ytes

The setjmp code sets r24 to 0 and checks if it is still 0 when it finishes.
This usually works because tinygo_longjmp stores the lower half of the stack pointer into r24.
However, r24 will be set to 0 if the stack is aligned to 256 bytes when entering the setjmp.

Manually set r24 to 1 in tinygo_longjmp to fix this issue.
Copy link
Member

@deadprogram deadprogram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another impressive find @niaow 🔍

@deadprogram
Copy link
Member

Another reference on why we need to do this: https://docs.rs/crate/avr-libc/latest/source/avr-libc/libc/stdlib/setjmp.S#131

@niaow niaow merged commit 0172302 into tinygo-org:dev Dec 5, 2025
19 checks passed
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.

2 participants