Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/lgc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down