From 1f2bdf936b6856b6ecff6a79f5dfd4085db1adb1 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Mon, 6 Nov 2023 17:53:14 +0100 Subject: [PATCH] driver: Fix startup crash when fuzzing native libraries (#883) driver: Fix startup crashes when fuzzing native libraries Fixes a JVM crash with the following frame while fuzzing native libraries: ``` [libstdc++.so.6+0x13bf8a] std::ostream::sentry::sentry(std::ostream&)+0x1a ``` --- .../code_intelligence/jazzer/driver/libfuzzer_callbacks.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/native/com/code_intelligence/jazzer/driver/libfuzzer_callbacks.cpp b/src/main/native/com/code_intelligence/jazzer/driver/libfuzzer_callbacks.cpp index b7a0df5d9..b576f0f13 100644 --- a/src/main/native/com/code_intelligence/jazzer/driver/libfuzzer_callbacks.cpp +++ b/src/main/native/com/code_intelligence/jazzer/driver/libfuzzer_callbacks.cpp @@ -119,6 +119,9 @@ extern "C" [[maybe_unused]] bool __sanitizer_weak_is_relevant_pc( Java_com_code_1intelligence_jazzer_runtime_TraceDataFlowNativeCallbacks_handleLibraryLoad( JNIEnv *, jclass) { std::call_once(ignore_list_flag, [] { + // Force std::cout to be fully initialized. + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26123 + static std::ios_base::Init initIostreams; std::cout << "INFO: detected a native library load, enabling interception " "for libc functions" << std::endl;