diff --git a/runtime/src/main/cpp/Memory.cpp b/runtime/src/main/cpp/Memory.cpp index da581d3b9a2..597698a405a 100644 --- a/runtime/src/main/cpp/Memory.cpp +++ b/runtime/src/main/cpp/Memory.cpp @@ -1859,6 +1859,7 @@ void deinitMemory(MemoryState* memoryState) { konan::consoleErrorf( "Memory leaks detected, %d objects leaked!\n" "Use `Platform.isMemoryLeakCheckerActive = false` to avoid this check.\n", allocCount); + konan::consoleFlush(); konan::abort(); } #endif // USE_GC diff --git a/runtime/src/main/cpp/Porting.cpp b/runtime/src/main/cpp/Porting.cpp index 12633d4dbcc..58a1d59e48a 100644 --- a/runtime/src/main/cpp/Porting.cpp +++ b/runtime/src/main/cpp/Porting.cpp @@ -172,6 +172,11 @@ void consoleErrorf(const char* format, ...) { consoleErrorUtf8(buffer, rv); } +void consoleFlush() { + ::fflush(stdout); + ::fflush(stderr); +} + // Thread execution. #if !KONAN_NO_THREADS diff --git a/runtime/src/main/cpp/Porting.h b/runtime/src/main/cpp/Porting.h index 80327e28e64..59693a538c6 100644 --- a/runtime/src/main/cpp/Porting.h +++ b/runtime/src/main/cpp/Porting.h @@ -32,6 +32,7 @@ void consoleWriteUtf8(const void* utf8, uint32_t sizeBytes); void consoleErrorUtf8(const void* utf8, uint32_t sizeBytes); // Negative return value denotes that read wasn't successful. int32_t consoleReadUtf8(void* utf8, uint32_t maxSizeBytes); +void consoleFlush(); // Process control. RUNTIME_NORETURN void abort(void); diff --git a/runtime/src/main/cpp/Worker.cpp b/runtime/src/main/cpp/Worker.cpp index 47f78e62142..be75ae930e9 100644 --- a/runtime/src/main/cpp/Worker.cpp +++ b/runtime/src/main/cpp/Worker.cpp @@ -493,6 +493,7 @@ class State { "Unfinished workers detected, %lu workers leaked!\n" "Use `Platform.isMemoryLeakCheckerActive = false` to avoid this check.\n", remainingNativeWorkers); + konan::consoleFlush(); konan::abort(); } }