Skip to content

Commit 550b519

Browse files
committed
runtime (avr): fix infinite longjmp loop if stack is aligned to 256 bytes
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.
1 parent 505b5ee commit 550b519

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/runtime/asm_avr.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,8 @@ tinygo_longjmp:
7878
ld r28, X+
7979
ld r29, X+
8080

81+
; Mark that we returned from a longjmp.
82+
ldi r24, 1
83+
8184
; Jump to the PC (stored in the Z register)
8285
icall

0 commit comments

Comments
 (0)