Don't use destroyed lock when profiler has been stopped.

Reported by Miku AuahDark. #1482 #1460
This commit is contained in:
Mike Pall 2026-07-09 10:24:06 +02:00
parent acb223497d
commit fed6d4782a

View File

@ -359,6 +359,7 @@ LUA_API void luaJIT_profile_stop(lua_State *L)
ProfileState *ps = &profile_state; ProfileState *ps = &profile_state;
global_State *g = ps->g; global_State *g = ps->g;
if (G(L) == g) { /* Only stop profiler if started by this VM. */ if (G(L) == g) { /* Only stop profiler if started by this VM. */
ps->g = NULL;
profile_timer_stop(ps); profile_timer_stop(ps);
g->hookmask &= ~HOOK_PROFILE; g->hookmask &= ~HOOK_PROFILE;
lj_dispatch_update(g, 0); lj_dispatch_update(g, 0);
@ -368,7 +369,6 @@ LUA_API void luaJIT_profile_stop(lua_State *L)
#endif #endif
lj_buf_free(g, &ps->sb); lj_buf_free(g, &ps->sb);
ps->sb.w = ps->sb.e = NULL; ps->sb.w = ps->sb.e = NULL;
ps->g = NULL;
} }
} }