Skip to content

Commit 646ec2c

Browse files
committed
fix(port_std): in catch_longjmp, restore lr and fp after the closure returns without calling longjmp
1 parent 9ea91be commit 646ec2c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/r3_port_std/src/threading_unix.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,22 +381,20 @@ fn catch_longjmp<F: FnOnce(JmpBuf)>(cb: F) {
381381
() => {
382382
asm!(
383383
"
384-
# push context
384+
# push context. jump to 0 if longjmp is called
385385
adr x2, 0f
386386
str x2, [sp, #-32]!
387387
stp x29, x30, [sp, #16]
388388
389389
# do f(ctx, jmp_buf)
390-
# [rdi = ctx, rsp = jmp_buf]
390+
# [x0 = ctx, x1 = jmp_buf]
391391
mov x1, sp
392392
blr {f}
393393
394-
b 1f
395394
0:
396-
# longjmp called. restore context
395+
# restore lr and fp
397396
ldp x29, x30, [sp, #16]
398397
399-
1:
400398
# discard context
401399
add sp, sp, #32
402400
",

0 commit comments

Comments
 (0)