FFI: Mark cts->L in atomic phase.

Reported by zyxwvu Shi. #1506
This commit is contained in:
Mike Pall 2026-08-18 15:01:31 +02:00
parent 5ed524c09f
commit 71797fa75f
2 changed files with 5 additions and 0 deletions

View File

@ -533,6 +533,7 @@ lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf)
lua_State *L = cts->L; lua_State *L = cts->L;
global_State *g = cts->g; global_State *g = cts->g;
lua_assert(L != NULL); lua_assert(L != NULL);
lua_assert(!isdead(g, obj2gco(L)));
if (gcref(g->jit_L)) { if (gcref(g->jit_L)) {
setstrV(L, L->top++, lj_err_str(L, LJ_ERR_FFI_BADCBACK)); setstrV(L, L->top++, lj_err_str(L, LJ_ERR_FFI_BADCBACK));
if (g->panic) g->panic(L); if (g->panic) g->panic(L);

View File

@ -586,6 +586,10 @@ static void atomic(global_State *g, lua_State *L)
setgcrefnull(g->gc.weak); setgcrefnull(g->gc.weak);
lua_assert(!iswhite(obj2gco(mainthread(g)))); lua_assert(!iswhite(obj2gco(mainthread(g))));
gc_markobj(g, L); /* Mark running thread. */ gc_markobj(g, L); /* Mark running thread. */
#if LJ_HASFFI
if (ctype_ctsG(g) && ctype_ctsG(g)->L) /* Mark cts->L thread. */
gc_markobj(g, ctype_ctsG(g)->L);
#endif
gc_traverse_curtrace(g); /* Traverse current trace. */ gc_traverse_curtrace(g); /* Traverse current trace. */
gc_mark_gcroot(g); /* Mark GC roots (again). */ gc_mark_gcroot(g); /* Mark GC roots (again). */
gc_propagate_gray(g); /* Propagate all of the above. */ gc_propagate_gray(g); /* Propagate all of the above. */