Make sure leak detector properly works in case of workers. (#3495)

This commit is contained in:
Nikolay Igotti
2019-10-25 13:32:19 +03:00
committed by GitHub
parent ac97437ddb
commit 8efb8cacc3
3 changed files with 11 additions and 0 deletions
+4
View File
@@ -265,4 +265,8 @@ KBoolean Konan_Platform_isDebugBinary() {
return KonanNeedDebugInfo ? true : false;
}
void Kotlin_zeroOutTLSGlobals() {
InitOrDeinitGlobalVariables(DEINIT_THREAD_LOCAL_GLOBALS);
}
} // extern "C"
+3
View File
@@ -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
+4
View File
@@ -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;
}