# HG changeset patch # User stuefe # Date 1562740225 -7200 # Wed Jul 10 08:30:25 2019 +0200 # Node ID a3c6b22da80181ead9d18bb2f8dab471e6e9ca2d # Parent 8bff79035c7e4fe24bfb7bfa63cc8c9f0b9f2c3b [mq]: 8227254-nestegg-buffer diff -r 8bff79035c7e -r a3c6b22da801 src/hotspot/share/runtime/globals.hpp --- a/src/hotspot/share/runtime/globals.hpp Tue Jul 09 17:00:34 2019 +0200 +++ b/src/hotspot/share/runtime/globals.hpp Wed Jul 10 08:30:25 2019 +0200 @@ -525,6 +525,10 @@ "error log in case of a crash.") \ range(0, (uint64_t)max_jlong/1000) \ \ + diagnostic(intx, NesteggSize, 0, \ + "A preallocated buffer which is used in case a native OOM " \ + "to improve error reporting.") \ + \ product_pd(bool, UseOSErrorReporting, \ "Let VM fatal error propagate to the OS (ie. WER on Windows)") \ \ diff -r 8bff79035c7e -r a3c6b22da801 src/hotspot/share/utilities/vmError.cpp --- a/src/hotspot/share/utilities/vmError.cpp Tue Jul 09 17:00:34 2019 +0200 +++ b/src/hotspot/share/utilities/vmError.cpp Wed Jul 10 08:30:25 2019 +0200 @@ -1375,6 +1375,13 @@ _error_reported = true; reporting_started(); + + // In case this is a native OOM, release the nestegg buffer - if there is one - + // to increase chance of error reporting functioning. + if (_id == (int)OOM_MALLOC_ERROR || _id == (int)OOM_MMAP_ERROR) { + release_nestegg(); + } + if (!TestUnresponsiveErrorHandler) { // Record reporting_start_time unless we're running the // TestUnresponsiveErrorHandler test. For that test we record @@ -1723,6 +1730,16 @@ } +static void* nestegg = NULL; +void VMError::prepare_nestegg() { + nestegg = os::malloc(NesteggSize, mtInternal); +} + +void VMError::release_nestegg() { + os::free(nestegg); + nestegg = NULL; +} + #ifndef PRODUCT #if defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5140 #pragma error_messages(off, SEC_NULL_PTR_DEREF) diff -r 8bff79035c7e -r a3c6b22da801 src/hotspot/share/utilities/vmError.hpp --- a/src/hotspot/share/utilities/vmError.hpp Tue Jul 09 17:00:34 2019 +0200 +++ b/src/hotspot/share/utilities/vmError.hpp Wed Jul 10 08:30:25 2019 +0200 @@ -195,5 +195,9 @@ // returns an address which is guaranteed to generate a SIGSEGV on read, // for test purposes, which is not NULL and contains bits in every word static void* get_segfault_address(); + + static void prepare_nestegg(); + static void release_nestegg(); + }; #endif // SHARE_UTILITIES_VMERROR_HPP