--- old/src/hotspot/share/runtime/globals.hpp 2019-07-03 19:31:04.638229617 +0200 +++ new/src/hotspot/share/runtime/globals.hpp 2019-07-03 19:31:04.210228530 +0200 @@ -505,6 +505,9 @@ notproduct(bool, TestUnresponsiveErrorHandler, false, \ "If true, simulates an unresponsive error handler.") \ \ + diagnostic(uintx, NesteggSize, 0, \ + "Pre-reserved memory size for error handling.") \ + \ develop(bool, Verbose, false, \ "Print additional debugging information from other modes") \ \ --- old/src/hotspot/share/runtime/os.cpp 2019-07-03 19:31:06.102233367 +0200 +++ new/src/hotspot/share/runtime/os.cpp 2019-07-03 19:31:05.606232092 +0200 @@ -795,6 +795,17 @@ #endif } +static void* p_nestegg = NULL; +bool os::init_nestegg(size_t size) { + p_nestegg = os::malloc(size, mtInternal); + return p_nestegg != NULL; +} + +void os::release_nestegg() { + os::free(p_nestegg); + p_nestegg = NULL; +} + void os::init_random(unsigned int initval) { _rand_seed = initval; } --- old/src/hotspot/share/runtime/os.hpp 2019-07-03 19:31:07.402236751 +0200 +++ new/src/hotspot/share/runtime/os.hpp 2019-07-03 19:31:06.950235568 +0200 @@ -742,6 +742,9 @@ // Like strdup, but exit VM when strdup() returns NULL static char* strdup_check_oom(const char*, MEMFLAGS flags = mtInternal); + static bool init_nestegg(size_t size); + static void release_nestegg(); + #ifndef PRODUCT static julong num_mallocs; // # of calls to malloc/realloc static julong alloc_bytes; // # of bytes allocated --- old/src/hotspot/share/runtime/thread.cpp 2019-07-03 19:31:08.598239904 +0200 +++ new/src/hotspot/share/runtime/thread.cpp 2019-07-03 19:31:08.186238812 +0200 @@ -3809,6 +3809,10 @@ jint os_init_2_result = os::init_2(); if (os_init_2_result != JNI_OK) return os_init_2_result; + if (NesteggSize > 0) { + os::init_nestegg(NesteggSize); + } + #ifdef CAN_SHOW_REGISTERS_ON_ASSERT // Initialize assert poison page mechanism. if (ShowRegistersOnAssert) { --- old/src/hotspot/share/utilities/vmError.cpp 2019-07-03 19:31:10.158244074 +0200 +++ new/src/hotspot/share/utilities/vmError.cpp 2019-07-03 19:31:09.706242860 +0200 @@ -1370,6 +1370,10 @@ // first time _error_reported = true; + if (_id == OOM_MALLOC_ERROR || _id == OOM_MMAP_ERROR) { + os::release_nestegg(); + } + reporting_started(); if (!TestUnresponsiveErrorHandler) { // Record reporting_start_time unless we're running the