--- old/src/os/aix/vm/os_aix.cpp 2015-03-12 11:02:54.396994169 -0700 +++ new/src/os/aix/vm/os_aix.cpp 2015-03-12 11:02:54.275988097 -0700 @@ -1224,7 +1224,7 @@ // Note: os::abort() might be called very early during initialization, or // called from signal handler. Before adding something to os::abort(), make // sure it is async-safe and can handle partially initialized VM. -void os::abort(bool dump_core) { +void os::abort(bool dump_core, void* exceptionRecord, void* contextRecord) { os::shutdown(); if (dump_core) { #ifndef PRODUCT --- old/src/os/bsd/vm/os_bsd.cpp 2015-03-12 11:02:54.969022873 -0700 +++ new/src/os/bsd/vm/os_bsd.cpp 2015-03-12 11:02:54.846016703 -0700 @@ -1145,7 +1145,7 @@ // Note: os::abort() might be called very early during initialization, or // called from signal handler. Before adding something to os::abort(), make // sure it is async-safe and can handle partially initialized VM. -void os::abort(bool dump_core) { +void os::abort(bool dump_core, void* exceptionRecord, void* contextRecord) { os::shutdown(); if (dump_core) { #ifndef PRODUCT --- old/src/os/linux/vm/os_linux.cpp 2015-03-12 11:02:55.461047564 -0700 +++ new/src/os/linux/vm/os_linux.cpp 2015-03-12 11:02:55.344041694 -0700 @@ -1513,7 +1513,7 @@ // Note: os::abort() might be called very early during initialization, or // called from signal handler. Before adding something to os::abort(), make // sure it is async-safe and can handle partially initialized VM. -void os::abort(bool dump_core) { +void os::abort(bool dump_core, void* exceptionRecord, void* contextRecord) { os::shutdown(); if (dump_core) { #ifndef PRODUCT --- old/src/os/posix/vm/os_posix.cpp 2015-03-12 11:02:55.986073908 -0700 +++ new/src/os/posix/vm/os_posix.cpp 2015-03-12 11:02:55.871068138 -0700 @@ -46,7 +46,7 @@ #define IS_VALID_PID(p) (p > 0 && p < MAX_PID) // Check core dump limit and report possible place where core can be found -void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) { +void os::check_create_dump_limit(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) { int n; struct rlimit rlim; bool success; --- old/src/os/solaris/vm/os_solaris.cpp 2015-03-12 11:02:56.527101058 -0700 +++ new/src/os/solaris/vm/os_solaris.cpp 2015-03-12 11:02:56.408095085 -0700 @@ -1531,7 +1531,7 @@ // Note: os::abort() might be called very early during initialization, or // called from signal handler. Before adding something to os::abort(), make // sure it is async-safe and can handle partially initialized VM. -void os::abort(bool dump_core) { +void os::abort(bool dump_core, void* exceptionRecord, void* contextRecord) { os::shutdown(); if (dump_core) { #ifndef PRODUCT --- old/src/os/windows/vm/os_windows.cpp 2015-03-12 11:02:57.074128507 -0700 +++ new/src/os/windows/vm/os_windows.cpp 2015-03-12 11:02:56.952122385 -0700 @@ -988,7 +988,11 @@ PMINIDUMP_USER_STREAM_INFORMATION, PMINIDUMP_CALLBACK_INFORMATION); -void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) { +void os::check_create_dump_limit(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) { + // do nothing, check done in function abort below. +} + +void os::abort(bool dump_core, void* exceptionRecord, void* contextRecord) { HINSTANCE dbghelp; EXCEPTION_POINTERS ep; MINIDUMP_EXCEPTION_INFORMATION mei; @@ -999,20 +1003,24 @@ HANDLE dumpFile; MINIDUMP_TYPE dumpType; static const char* cwd; + static char buffer[O_BUFLEN]; -// Default is to always create dump for debug builds, on product builds only dump on server versions of Windows. + os::shutdown(); + if (!dump_core) return; + + // Default is to always create dump for debug builds, on product builds only dump on server versions of Windows. #ifndef ASSERT // If running on a client version of Windows and user has not explicitly enabled dumping - if (!os::win32::is_windows_server() && !CreateMinidumpOnCrash) { + if (!os::win32::is_windows_server() && !CreateCoredumpOnCrash) { VMError::report_coredump_status("Minidumps are not enabled by default on client versions of Windows", false); return; // If running on a server version of Windows and user has explictly disabled dumping - } else if (os::win32::is_windows_server() && !FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) { + } else if (os::win32::is_windows_server() && !FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) { VMError::report_coredump_status("Minidump has been disabled from the command line", false); return; } #else - if (!FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) { + if (!FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) { VMError::report_coredump_status("Minidump has been disabled from the command line", false); return; } @@ -1048,13 +1056,14 @@ #endif cwd = get_current_directory(NULL, 0); - jio_snprintf(buffer, bufferSize, "%s\\hs_err_pid%u.mdmp", cwd, current_process_id()); + jio_snprintf(buffer, sizeof(buffer), "%s\\hs_err_pid%u.mdmp", cwd, current_process_id()); dumpFile = CreateFile(buffer, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (dumpFile == INVALID_HANDLE_VALUE) { VMError::report_coredump_status("Failed to create file for dumping", false); return; } + if (exceptionRecord != NULL && contextRecord != NULL) { ep.ContextRecord = (PCONTEXT) contextRecord; ep.ExceptionRecord = (PEXCEPTION_RECORD) exceptionRecord; @@ -1079,11 +1088,11 @@ FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR)&msgbuf, 0, NULL) != 0) { - jio_snprintf(buffer, bufferSize, "Call to MiniDumpWriteDump() failed (Error 0x%x: %s)", error, msgbuf); + jio_snprintf(buffer, sizeof(buffer), "Call to MiniDumpWriteDump() failed (Error 0x%x: %s)", error, msgbuf); LocalFree(msgbuf); } else { // Call to FormatMessage failed, just include the result from GetLastError - jio_snprintf(buffer, bufferSize, "Call to MiniDumpWriteDump() failed (Error 0x%x)", error); + jio_snprintf(buffer, sizeof(buffer), "Call to MiniDumpWriteDump() failed (Error 0x%x)", error); } VMError::report_coredump_status(buffer, false); } else { @@ -1091,12 +1100,6 @@ } CloseHandle(dumpFile); -} - - -void os::abort(bool dump_core) { - os::shutdown(); - // no core dump on Windows win32::exit_process_or_thread(win32::EPT_PROCESS, 1); } --- old/src/share/vm/runtime/arguments.cpp 2015-03-12 11:02:57.635156660 -0700 +++ new/src/share/vm/runtime/arguments.cpp 2015-03-12 11:02:57.513150537 -0700 @@ -3300,6 +3300,15 @@ "ManagementServer is not supported in this VM.\n"); return JNI_ERR; #endif // INCLUDE_MANAGEMENT + // CreateMinidumpOnCrash is removed, and replaced by CreateCoredumpOnCrash + } else if (match_option(option, "-XX:+CreateMinidumpOnCrash", &tail)) { + FLAG_SET_CMDLINE(bool, CreateCoredumpOnCrash, true); + jio_fprintf(defaultStream::output_stream(), + "CreateMinidumpOnCrash is replaced by CreateCoredumpOnCrash: CreateCoredumpOnCrash is on\n"); + } else if (match_option(option, "-XX:-CreateMinidumpOnCrash", &tail)) { + FLAG_SET_CMDLINE(bool, CreateCoredumpOnCrash, false); + jio_fprintf(defaultStream::output_stream(), + "CreateMinidumpOnCrash is replaced by CreateCoredumpOnCrash: CreateCoredumpOnCrash is off\n"); } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx // Skip -XX:Flags= since that case has already been handled if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) { --- old/src/share/vm/runtime/globals.hpp 2015-03-12 11:02:58.177183858 -0700 +++ new/src/share/vm/runtime/globals.hpp 2015-03-12 11:02:58.038176882 -0700 @@ -933,7 +933,7 @@ product(bool, ShowMessageBoxOnError, false, \ "Keep process alive on VM fatal error") \ \ - product(bool, CreateMinidumpOnCrash, false, \ + product(bool, CreateCoredumpOnCrash, true, \ "Create minidump on VM fatal error") \ \ product_pd(bool, UseOSErrorReporting, \ --- old/src/share/vm/runtime/os.hpp 2015-03-12 11:02:58.743212261 -0700 +++ new/src/share/vm/runtime/os.hpp 2015-03-12 11:02:58.607205437 -0700 @@ -493,7 +493,7 @@ // Terminate with an error. Default is to generate a core file on platforms // that support such things. This calls shutdown() and then aborts. - static void abort(bool dump_core = true); + static void abort(bool dump_core = true, void *siginfo = NULL, void *context = NULL); // Die immediately, no exit hook, no abort hook, no cleanup. static void die(); @@ -718,7 +718,7 @@ static void os_exception_wrapper(java_call_t f, JavaValue* value, methodHandle* method, JavaCallArguments* args, Thread* thread); // On Windows this will create an actual minidump, on Linux/Solaris it will simply check core dump limits - static void check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize); + static void check_create_dump_limit(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize); // Get the default path to the core file // Returns the length of the string --- old/src/share/vm/utilities/vmError.cpp 2015-03-12 11:02:59.203235345 -0700 +++ new/src/share/vm/utilities/vmError.cpp 2015-03-12 11:02:59.082229273 -0700 @@ -505,10 +505,14 @@ } STEP(63, "(printing core file information)") st->print("# "); - if (coredump_status) { - st->print("Core dump written. Default location: %s", coredump_message); + if (CreateCoredumpOnCrash) { + if (coredump_status) { + st->print("Core dump written. Default location: %s", coredump_message); + } else { + st->print("Failed to write core dump. %s", coredump_message); + } } else { - st->print("Failed to write core dump. %s", coredump_message); + st->print("CreateCoredumpOnCrash turned off, no core file dumped"); } st->cr(); st->print_cr("#"); @@ -898,7 +902,7 @@ static bool transmit_report_done = false; // done error reporting if (SuppressFatalErrorMessage) { - os::abort(); + os::abort(CreateCoredumpOnCrash); } jlong mytid = os::current_thread_id(); if (first_error == NULL && @@ -916,8 +920,8 @@ ShowMessageBoxOnError = false; } - // Write a minidump on Windows, check core dump limits on Linux/Solaris - os::check_or_create_dump(_siginfo, _context, buffer, sizeof(buffer)); + // check core dump limits on Linux/Solaris, nothing on Windows + os::check_create_dump_limit(_siginfo, _context, buffer, sizeof(buffer)); // reset signal handlers or exception filter; make sure recursive crashes // are handled properly. @@ -1088,7 +1092,7 @@ if (!skip_os_abort) { skip_os_abort = true; bool dump_core = should_report_bug(first_error->_id); - os::abort(dump_core); + os::abort(dump_core && CreateCoredumpOnCrash, _siginfo, _context); } // if os::abort() doesn't abort, try os::die(); --- old/test/runtime/ErrorHandling/ProblematicFrameTest.java 2015-03-12 11:02:59.687259634 -0700 +++ new/test/runtime/ErrorHandling/ProblematicFrameTest.java 2015-03-12 11:02:59.573253913 -0700 @@ -44,7 +44,7 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xmx64m", "-XX:-TransmitErrorReport", "-XX:-CreateMinidumpOnCrash", Crasher.class.getName()); + "-Xmx64m", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotMatch("error occurred during error reporting \\(printing problematic frame\\)"); } --- old/test/runtime/ErrorHandling/SecondaryErrorTest.java 2015-03-12 11:03:00.191284925 -0700 +++ new/test/runtime/ErrorHandling/SecondaryErrorTest.java 2015-03-12 11:03:00.076279155 -0700 @@ -33,6 +33,7 @@ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", + "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=15", "-XX:TestCrashInErrorHandler=14", "-version"); --- old/test/runtime/Safepoint/AssertSafepointCheckConsistency1.java 2015-03-12 11:03:00.693310117 -0700 +++ new/test/runtime/Safepoint/AssertSafepointCheckConsistency1.java 2015-03-12 11:03:00.579304396 -0700 @@ -47,7 +47,7 @@ "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:-TransmitErrorReport", - "-XX:-CreateMinidumpOnCrash", + "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "AssertSafepointCheckConsistency1", "test"); --- old/test/runtime/Safepoint/AssertSafepointCheckConsistency2.java 2015-03-12 11:03:01.264338770 -0700 +++ new/test/runtime/Safepoint/AssertSafepointCheckConsistency2.java 2015-03-12 11:03:01.145332799 -0700 @@ -47,7 +47,7 @@ "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:-TransmitErrorReport", - "-XX:-CreateMinidumpOnCrash", + "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "AssertSafepointCheckConsistency2", "test"); --- old/test/runtime/Safepoint/AssertSafepointCheckConsistency3.java 2015-03-12 11:03:01.922371790 -0700 +++ new/test/runtime/Safepoint/AssertSafepointCheckConsistency3.java 2015-03-12 11:03:01.780364666 -0700 @@ -47,7 +47,7 @@ "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:-TransmitErrorReport", - "-XX:-CreateMinidumpOnCrash", + "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "AssertSafepointCheckConsistency3", "test"); --- old/test/runtime/Safepoint/AssertSafepointCheckConsistency4.java 2015-03-12 11:03:02.457398638 -0700 +++ new/test/runtime/Safepoint/AssertSafepointCheckConsistency4.java 2015-03-12 11:03:02.341392818 -0700 @@ -47,7 +47,7 @@ "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:-TransmitErrorReport", - "-XX:-CreateMinidumpOnCrash", + "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "AssertSafepointCheckConsistency4", "test");