Make sure leak detector properly works in case of workers. (#3495)
This commit is contained in:
@@ -265,4 +265,8 @@ KBoolean Konan_Platform_isDebugBinary() {
|
||||
return KonanNeedDebugInfo ? true : false;
|
||||
}
|
||||
|
||||
void Kotlin_zeroOutTLSGlobals() {
|
||||
InitOrDeinitGlobalVariables(DEINIT_THREAD_LOCAL_GLOBALS);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -50,6 +50,9 @@ bool Kotlin_hasRuntime();
|
||||
// Appends given node to an initializer list.
|
||||
void AppendToInitializersTail(struct InitNode*);
|
||||
|
||||
// Zero out all Kotlin thread local globals.
|
||||
void Kotlin_zeroOutTLSGlobals();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -466,6 +466,10 @@ void* workerRoutine(void* argument) {
|
||||
if (worker->processQueueElement(true) == JOB_TERMINATE) break;
|
||||
} while (true);
|
||||
|
||||
// Runtime deinit callback could be called when TLS is already zeroed out, so clear memory
|
||||
// here explicitly. to make sure leak detector properly works.
|
||||
Kotlin_zeroOutTLSGlobals();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user