diff --git a/src/hotspot/share/utilities/debug.cpp b/src/hotspot/share/utilities/debug.cpp index 62a6bcf99bc..c566addef32 100644 --- a/src/hotspot/share/utilities/debug.cpp +++ b/src/hotspot/share/utilities/debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -254,8 +254,7 @@ void report_vm_status_error(const char* file, int line, const char* error_msg, report_vm_error(file, line, error_msg, "error %s(%d), %s", os::errno_name(status), status, detail); } -void report_fatal(const char* file, int line, const char* detail_fmt, ...) -{ +void report_fatal(VMErrorType error_type, const char* file, int line, const char* detail_fmt, ...) { if (Debugging || error_is_suppressed(file, line)) return; va_list detail_args; va_start(detail_args, detail_fmt); @@ -265,7 +264,9 @@ void report_fatal(const char* file, int line, const char* detail_fmt, ...) context = g_assertion_context; } #endif // CAN_SHOW_REGISTERS_ON_ASSERT - VMError::report_and_die(Thread::current_or_null(), context, file, line, "fatal error", detail_fmt, detail_args); + VMError::report_and_die(error_type, "fatal error", detail_fmt, detail_args, + Thread::current_or_null(), NULL, NULL, context, + file, line, 0); va_end(detail_args); } @@ -335,7 +336,7 @@ void report_java_out_of_memory(const char* message) { if (CrashOnOutOfMemoryError) { tty->print_cr("Aborting due to java.lang.OutOfMemoryError: %s", message); - fatal("OutOfMemory encountered: %s", message); + report_fatal(OOM_JAVA_HEAP_FATAL, __FILE__, __LINE__, "OutOfMemory encountered: %s", message); } if (ExitOnOutOfMemoryError) { @@ -770,4 +771,3 @@ bool handle_assert_poison_fault(const void* ucVoid, const void* faulting_address return false; } #endif // CAN_SHOW_REGISTERS_ON_ASSERT - diff --git a/src/hotspot/share/utilities/debug.hpp b/src/hotspot/share/utilities/debug.hpp index a0b0bd1cfea..56bb226bc62 100644 --- a/src/hotspot/share/utilities/debug.hpp +++ b/src/hotspot/share/utilities/debug.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,7 +109,7 @@ do { #define fatal(...) \ do { \ TOUCH_ASSERT_POISON; \ - report_fatal(__FILE__, __LINE__, __VA_ARGS__); \ + report_fatal(INTERNAL_ERROR, __FILE__, __LINE__, __VA_ARGS__); \ BREAKPOINT; \ } while (0) @@ -152,7 +152,9 @@ do { enum VMErrorType { INTERNAL_ERROR = 0xe0000000, OOM_MALLOC_ERROR = 0xe0000001, - OOM_MMAP_ERROR = 0xe0000002 + OOM_MMAP_ERROR = 0xe0000002, + OOM_MPROTECT_ERROR = 0xe0000003, + OOM_JAVA_HEAP_FATAL = 0xe0000004 }; // error reporting helper functions @@ -174,7 +176,7 @@ void report_assert_msg(const char* msg, ...); #endif void report_vm_status_error(const char* file, int line, const char* error_msg, int status, const char* detail); -void report_fatal(const char* file, int line, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(3, 4); +void report_fatal(VMErrorType error_type, const char* file, int line, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5); void report_vm_out_of_memory(const char* file, int line, size_t size, VMErrorType vm_err_type, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(5, 6); void report_should_not_call(const char* file, int line); diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 96d8a292f5f..9ea100737f9 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -604,7 +604,7 @@ void VMError::report(outputStream* st, bool _verbose) { STEP("printing bug submit message") - if (should_report_bug(_id) && _verbose) { + if (should_submit_bug_report(_id) && _verbose) { print_bug_submit_message(st, _thread); } @@ -1555,7 +1555,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt } } - static bool skip_bug_url = !should_report_bug(_id); + static bool skip_bug_url = !should_submit_bug_report(_id); if (!skip_bug_url) { skip_bug_url = true; diff --git a/src/hotspot/share/utilities/vmError.hpp b/src/hotspot/share/utilities/vmError.hpp index fa9c9d0d209..e53e5760437 100644 --- a/src/hotspot/share/utilities/vmError.hpp +++ b/src/hotspot/share/utilities/vmError.hpp @@ -114,6 +114,10 @@ class VMError : public AllStatic { return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR); } + static bool should_submit_bug_report(unsigned int id) { + return should_report_bug(id) && (id != OOM_JAVA_HEAP_FATAL); + } + // Write a hint to the stream in case siginfo relates to a segv/bus error // and the offending address points into CDS store. static void check_failing_cds_access(outputStream* st, const void* siginfo);