[K/N] Better fix for calls checker use-after-free in main thread deinit
This commit is contained in:
committed by
Space Team
parent
3429bccf9a
commit
c04e1b6ce7
@@ -113,12 +113,12 @@ extern "C" void DeinitMemory(MemoryState* state, bool destroyRuntime) {
|
||||
AssertThreadState(state, ThreadState::kNative);
|
||||
auto* node = mm::FromMemoryState(state);
|
||||
if (destroyRuntime) {
|
||||
{
|
||||
ThreadStateGuard guard(state, ThreadState::kRunnable);
|
||||
node->Get()->gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
// TODO: Why not just destruct `GC` object and its thread data counterpart entirely?
|
||||
mm::GlobalData::Instance().gc().StopFinalizerThreadIfRunning();
|
||||
}
|
||||
ThreadStateGuard guard(state, ThreadState::kRunnable);
|
||||
node->Get()->gc().ScheduleAndWaitFullGCWithFinalizers();
|
||||
// TODO: Why not just destruct `GC` object and its thread data counterpart entirely?
|
||||
mm::GlobalData::Instance().gc().StopFinalizerThreadIfRunning();
|
||||
}
|
||||
if (!konan::isOnThreadExitNotSetOrAlreadyStarted()) {
|
||||
// we can clear reference in advance, as Unregister function can't use it anyway
|
||||
mm::ThreadRegistry::ClearCurrentThreadData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user