From a622e2eb559c823d90c7af85935ca63706e4593d Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 20 Sep 2021 14:34:47 +0200 Subject: FFI: Fix missing cts->L initialization in argv2ctype(). --- src/lj_crecord.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lj_crecord.c b/src/lj_crecord.c index 70305069..91a81519 100644 --- a/src/lj_crecord.c +++ b/src/lj_crecord.c @@ -76,7 +76,7 @@ static CTypeID argv2ctype(jit_State *J, TRef tr, cTValue *o) /* Specialize to the string containing the C type declaration. */ emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, s)); cp.L = J->L; - cp.cts = ctype_ctsG(J2G(J)); + cp.cts = ctype_cts(J->L); oldtop = cp.cts->top; cp.srcname = strdata(s); cp.p = strdata(s); -- cgit v1.2.3-55-g6feb From 68ffbd318b331b988c32ecfdeee965e9683889f4 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 20 Sep 2021 14:36:52 +0200 Subject: FFI: Don't load PC from non-function object in FFI continuation. Reported by Yichun Zhang. #743 --- src/vm_arm.dasc | 2 +- src/vm_mips.dasc | 2 +- src/vm_ppc.dasc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vm_arm.dasc b/src/vm_arm.dasc index 21d706d8..344147e8 100644 --- a/src/vm_arm.dasc +++ b/src/vm_arm.dasc @@ -524,13 +524,13 @@ static void build_subroutines(BuildCtx *ctx) | cmp CARG1, #1 |.endif | ldr PC, [CARG4, #-12] // Restore PC from [cont|PC]. - | ldr CARG3, LFUNC:CARG3->field_pc | mvn INS, #~LJ_TNIL | add CARG2, RA, RC | str INS, [CARG2, #-4] // Ensure one valid arg. |.if FFI | bls >1 |.endif + | ldr CARG3, LFUNC:CARG3->field_pc | ldr KBASE, [CARG3, #PC2PROTO(k)] | // BASE = base, RA = resultptr, CARG4 = meta base | bx CARG1 diff --git a/src/vm_mips.dasc b/src/vm_mips.dasc index 8cb4bd3d..03a84985 100644 --- a/src/vm_mips.dasc +++ b/src/vm_mips.dasc @@ -603,11 +603,11 @@ static void build_subroutines(BuildCtx *ctx) |.endif | lw PC, -16+HI(RB) // Restore PC from [cont|PC]. | addu TMP2, RA, RD - | lw TMP1, LFUNC:TMP1->pc |.if FFI | bnez AT, >1 |.endif |. sw TISNIL, -8+HI(TMP2) // Ensure one valid arg. + | lw TMP1, LFUNC:TMP1->pc | // BASE = base, RA = resultptr, RB = meta base | jr TMP0 // Jump to continuation. |. lw KBASE, PC2PROTO(k)(TMP1) diff --git a/src/vm_ppc.dasc b/src/vm_ppc.dasc index e2d62e00..9c1cc36f 100644 --- a/src/vm_ppc.dasc +++ b/src/vm_ppc.dasc @@ -819,11 +819,11 @@ static void build_subroutines(BuildCtx *ctx) |.endif | lwz PC, -16(RB) // Restore PC from [cont|PC]. | subi TMP2, RD, 8 - | lwz TMP1, LFUNC:TMP1->pc | stwx TISNIL, RA, TMP2 // Ensure one valid arg. |.if FFI | ble >1 |.endif + | lwz TMP1, LFUNC:TMP1->pc | lwz KBASE, PC2PROTO(k)(TMP1) | // BASE = base, RA = resultptr, RB = meta base | mtctr TMP0 -- cgit v1.2.3-55-g6feb