From d0f1296c7e6936b710ea3a3a43c32ff47cd29b70 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Tue, 12 Dec 2017 12:53:52 +0300 Subject: [PATCH] Rework deinit sequence to avoid bogus leak detector warnings. --- runtime/src/main/cpp/Porting.cpp | 2 +- runtime/src/main/cpp/Runtime.cpp | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/runtime/src/main/cpp/Porting.cpp b/runtime/src/main/cpp/Porting.cpp index e6359ea948e..55f4f2b8ee6 100644 --- a/runtime/src/main/cpp/Porting.cpp +++ b/runtime/src/main/cpp/Porting.cpp @@ -127,7 +127,7 @@ void onThreadExit(void (*destructor)()) { #ifdef KONAN_WASM // No way to do that. #else - ::atexit(destructor); +#error "How to do onThreadExit()?" #endif #else // !KONAN_NO_THREADS // We cannot use pthread_cleanup_push() as it is lexical scope bound. diff --git a/runtime/src/main/cpp/Runtime.cpp b/runtime/src/main/cpp/Runtime.cpp index 73e98353545..a64ea2bf847 100644 --- a/runtime/src/main/cpp/Runtime.cpp +++ b/runtime/src/main/cpp/Runtime.cpp @@ -82,15 +82,6 @@ void Kotlin_initRuntimeIfNeeded() { runtimeState = initRuntime(); // Register runtime deinit function at thread cleanup. konan::onThreadExit(Kotlin_deinitRuntimeIfNeeded); -#ifndef KONAN_WASM - // `onThreadExit` doesn't work on main thread, use `atexit`: - - static bool deinitScheduledAtexit = false; - if (!deinitScheduledAtexit) { - deinitScheduledAtexit = true; // Having data race is OK here. - ::atexit(Kotlin_deinitRuntimeIfNeeded); - } -#endif } }