diff --git a/src/lgc.c b/src/lgc.c index 116a058..d829d2a 100644 --- a/src/lgc.c +++ b/src/lgc.c @@ -1624,16 +1624,21 @@ void luaC_inherit_thread(lua_State *L, lua_State *th) { int i; GCheader *steal, *tmp; + thr_State *pt; if (th->heap == NULL) { // already done return; } + pt = luaC_get_per_thread(L); + /* when a thread is reclaimed, the executing thread * needs to steal its contents */ lock_all_threads(); + block_collector(L, pt); + if (TEST_INHERIT_THREAD_DELAY_MS > 0) { /* TR-1945: Both global trace and thread delref will grab * the "all threads" lock. To induce false contention on that lock @@ -1671,6 +1676,8 @@ void luaC_inherit_thread(lua_State *L, lua_State *th) make_grey(L, steal); } TAILQ_REMOVE(&G(L)->all_heaps, th->heap, heaps); + unblock_collector(L, pt); + unlock_all_threads(); free(th->heap);