9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include <fcntl.h> 26 #include "precompiled.hpp" 27 #include "compiler/compileBroker.hpp" 28 #include "gc_interface/collectedHeap.hpp" 29 #include "prims/whitebox.hpp" 30 #include "runtime/arguments.hpp" 31 #include "runtime/frame.inline.hpp" 32 #include "runtime/init.hpp" 33 #include "runtime/os.hpp" 34 #include "runtime/thread.inline.hpp" 35 #include "runtime/vmThread.hpp" 36 #include "runtime/vm_operations.hpp" 37 #include "services/memTracker.hpp" 38 #include "utilities/debug.hpp" 39 #include "utilities/decoder.hpp" 40 #include "utilities/defaultStream.hpp" 41 #include "utilities/errorReporter.hpp" 42 #include "utilities/events.hpp" 43 #include "utilities/top.hpp" 44 #include "utilities/vmError.hpp" 45 46 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 47 48 // List of environment variables that should be reported in error log file. 49 const char *env_list[] = { 50 // All platforms 51 "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH", 52 "JAVA_COMPILER", "PATH", "USERNAME", 53 54 // Env variables that are defined on Solaris/Linux/BSD 55 "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY", 56 "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE", 57 58 // defined on Linux 59 "LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM", 60 61 // defined on Darwin 62 "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH", 63 "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH", 64 "DYLD_INSERT_LIBRARIES", 922 923 // first time 924 first_error_tid = mytid; 925 set_error_reported(); 926 927 if (ShowMessageBoxOnError || PauseAtExit) { 928 show_message_box(buffer, sizeof(buffer)); 929 930 // User has asked JVM to abort. Reset ShowMessageBoxOnError so the 931 // WatcherThread can kill JVM if the error handler hangs. 932 ShowMessageBoxOnError = false; 933 } 934 935 // Write a minidump on Windows, check core dump limits on Linux/Solaris 936 os::check_or_create_dump(_siginfo, _context, buffer, sizeof(buffer)); 937 938 // reset signal handlers or exception filter; make sure recursive crashes 939 // are handled properly. 940 reset_signal_handlers(); 941 942 } else { 943 // If UseOsErrorReporting we call this for each level of the call stack 944 // while searching for the exception handler. Only the first level needs 945 // to be reported. 946 if (UseOSErrorReporting && log_done) return; 947 948 // This is not the first error, see if it happened in a different thread 949 // or in the same thread during error reporting. 950 if (first_error_tid != mytid) { 951 char msgbuf[64]; 952 jio_snprintf(msgbuf, sizeof(msgbuf), 953 "[thread " INT64_FORMAT " also had an error]", 954 mytid); 955 out.print_raw_cr(msgbuf); 956 957 // error reporting is not MT-safe, block current thread 958 os::infinite_sleep(); 959 960 } else { 961 if (recursive_error_count++ > 30) { | 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include <fcntl.h> 26 #include "precompiled.hpp" 27 #include "compiler/compileBroker.hpp" 28 #include "gc_interface/collectedHeap.hpp" 29 #include "jfr/jfrEvents.hpp" 30 #include "prims/whitebox.hpp" 31 #include "runtime/arguments.hpp" 32 #include "runtime/frame.inline.hpp" 33 #include "runtime/init.hpp" 34 #include "runtime/os.hpp" 35 #include "runtime/thread.inline.hpp" 36 #include "runtime/vmThread.hpp" 37 #include "runtime/vm_operations.hpp" 38 #include "services/memTracker.hpp" 39 #include "utilities/debug.hpp" 40 #include "utilities/decoder.hpp" 41 #include "utilities/defaultStream.hpp" 42 #include "utilities/errorReporter.hpp" 43 #include "utilities/events.hpp" 44 #include "utilities/top.hpp" 45 #include "utilities/vmError.hpp" 46 #include "utilities/macros.hpp" 47 #if INCLUDE_JFR 48 #include "jfr/jfr.hpp" 49 #endif 50 51 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 52 53 // List of environment variables that should be reported in error log file. 54 const char *env_list[] = { 55 // All platforms 56 "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH", 57 "JAVA_COMPILER", "PATH", "USERNAME", 58 59 // Env variables that are defined on Solaris/Linux/BSD 60 "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY", 61 "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE", 62 63 // defined on Linux 64 "LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM", 65 66 // defined on Darwin 67 "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH", 68 "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH", 69 "DYLD_INSERT_LIBRARIES", 927 928 // first time 929 first_error_tid = mytid; 930 set_error_reported(); 931 932 if (ShowMessageBoxOnError || PauseAtExit) { 933 show_message_box(buffer, sizeof(buffer)); 934 935 // User has asked JVM to abort. Reset ShowMessageBoxOnError so the 936 // WatcherThread can kill JVM if the error handler hangs. 937 ShowMessageBoxOnError = false; 938 } 939 940 // Write a minidump on Windows, check core dump limits on Linux/Solaris 941 os::check_or_create_dump(_siginfo, _context, buffer, sizeof(buffer)); 942 943 // reset signal handlers or exception filter; make sure recursive crashes 944 // are handled properly. 945 reset_signal_handlers(); 946 947 EventShutdown e; 948 if (e.should_commit()) { 949 e.set_reason("VM Error"); 950 e.commit(); 951 } 952 953 JFR_ONLY(Jfr::on_vm_shutdown(true);) 954 } else { 955 // If UseOsErrorReporting we call this for each level of the call stack 956 // while searching for the exception handler. Only the first level needs 957 // to be reported. 958 if (UseOSErrorReporting && log_done) return; 959 960 // This is not the first error, see if it happened in a different thread 961 // or in the same thread during error reporting. 962 if (first_error_tid != mytid) { 963 char msgbuf[64]; 964 jio_snprintf(msgbuf, sizeof(msgbuf), 965 "[thread " INT64_FORMAT " also had an error]", 966 mytid); 967 out.print_raw_cr(msgbuf); 968 969 // error reporting is not MT-safe, block current thread 970 os::infinite_sleep(); 971 972 } else { 973 if (recursive_error_count++ > 30) { |