< prev index next >

src/hotspot/share/utilities/vmError.cpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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  *


 131   const char *url = Arguments::java_vendor_url_bug();
 132   if (url == NULL || *url == '\0')
 133     url = JDK_Version::runtime_vendor_vm_bug_url();
 134   if (url != NULL && *url != '\0') {
 135     out->print_raw_cr("# If you would like to submit a bug report, please visit:");
 136     out->print_raw   ("#   ");
 137     out->print_raw_cr(url);
 138   }
 139   // If the crash is in native code, encourage user to submit a bug to the
 140   // provider of that code.
 141   if (thread && thread->is_Java_thread() &&
 142       !thread->is_hidden_from_external_view()) {
 143     JavaThread* jt = (JavaThread*)thread;
 144     if (jt->thread_state() == _thread_in_native) {
 145       out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug.");
 146     }
 147   }
 148   out->print_raw_cr("#");
 149 }
 150 




























 151 bool VMError::coredump_status;
 152 char VMError::coredump_message[O_BUFLEN];
 153 
 154 void VMError::record_coredump_status(const char* message, bool status) {
 155   coredump_status = status;
 156   strncpy(coredump_message, message, sizeof(coredump_message));
 157   coredump_message[sizeof(coredump_message)-1] = 0;
 158 }
 159 
 160 // Return a string to describe the error
 161 char* VMError::error_string(char* buf, int buflen) {
 162   char signame_buf[64];
 163   const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf));
 164 
 165   if (signame) {
 166     jio_snprintf(buf, buflen,
 167                  "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT,
 168                  signame, _id, _pc,
 169                  os::current_process_id(), os::current_thread_id());
 170   } else if (_filename != NULL && _lineno > 0) {


 601        frame fr = os::fetch_frame_from_context(_context);
 602        fr.print_on_error(st, buf, sizeof(buf));
 603        st->cr();
 604        st->print_cr("#");
 605      }
 606 
 607   STEP("printing core file information")
 608     st->print("# ");
 609     if (CreateCoredumpOnCrash) {
 610       if (coredump_status) {
 611         st->print("Core dump will be written. Default location: %s", coredump_message);
 612       } else {
 613         st->print("No core dump will be written. %s", coredump_message);
 614       }
 615     } else {
 616       st->print("CreateCoredumpOnCrash turned off, no core file dumped");
 617     }
 618     st->cr();
 619     st->print_cr("#");
 620 







 621   STEP("printing bug submit message")
 622 
 623      if (should_report_bug(_id) && _verbose) {
 624        print_bug_submit_message(st, _thread);
 625      }
 626 
 627   STEP("printing summary")
 628 
 629      if (_verbose) {
 630        st->cr();
 631        st->print_cr("---------------  S U M M A R Y ------------");
 632        st->cr();
 633      }
 634 
 635   STEP("printing VM option summary")
 636 
 637      if (_verbose) {
 638        // VM options
 639        Arguments::print_summary_on(st);
 640        st->cr();


1387 
1388     reporting_started();
1389     if (!TestUnresponsiveErrorHandler) {
1390       // Record reporting_start_time unless we're running the
1391       // TestUnresponsiveErrorHandler test. For that test we record
1392       // reporting_start_time at the beginning of the test.
1393       record_reporting_start_time();
1394     } else {
1395       out.print_raw_cr("Delaying recording reporting_start_time for TestUnresponsiveErrorHandler.");
1396     }
1397 
1398     if (ShowMessageBoxOnError || PauseAtExit) {
1399       show_message_box(buffer, sizeof(buffer));
1400 
1401       // User has asked JVM to abort. Reset ShowMessageBoxOnError so the
1402       // WatcherThread can kill JVM if the error handler hangs.
1403       ShowMessageBoxOnError = false;
1404     }
1405 
1406     os::check_dump_limit(buffer, sizeof(buffer));

1407 
1408     // reset signal handlers or exception filter; make sure recursive crashes
1409     // are handled properly.
1410     reset_signal_handlers();
1411 
1412     EventShutdown e;
1413     if (e.should_commit()) {
1414       e.set_reason("VM Error");
1415       e.commit();
1416     }
1417 
1418     JFR_ONLY(Jfr::on_vm_shutdown(true);)
1419 
1420   } else {
1421     // If UseOsErrorReporting we call this for each level of the call stack
1422     // while searching for the exception handler.  Only the first level needs
1423     // to be reported.
1424     if (UseOSErrorReporting && log_done) return;
1425 
1426     // This is not the first error, see if it happened in a different thread
1427     // or in the same thread during error reporting.
1428     if (_first_error_tid != mytid) {
1429       char msgbuf[64];
1430       jio_snprintf(msgbuf, sizeof(msgbuf),
1431                    "[thread " INTX_FORMAT " also had an error]",
1432                    mytid);
1433       out.print_raw_cr(msgbuf);
1434 
1435       // error reporting is not MT-safe, block current thread
1436       os::infinite_sleep();
1437 
1438     } else {
1439       if (recursive_error_count++ > 30) {


1520         } else {
1521           out.print_raw_cr("# Can not save log file, dump to screen..");
1522           fd_log = 1;
1523         }
1524       }
1525       log.set_fd(fd_log);
1526     }
1527 
1528     report(&log, true);
1529     log_done = true;
1530     _current_step = 0;
1531     _current_step_info = "";
1532 
1533     if (fd_log > 3) {
1534       close(fd_log);
1535       fd_log = -1;
1536     }
1537 
1538     log.set_fd(-1);
1539   }


1540 
1541   if (PrintNMTStatistics) {
1542     fdStream fds(fd_out);
1543     MemTracker::final_report(&fds);
1544   }
1545 
1546   static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay
1547   if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) {
1548     skip_replay = true;
1549     ciEnv* env = ciEnv::current();
1550     if (env != NULL) {
1551       const bool overwrite = false; // We do not overwrite an existing replay file.
1552       int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", overwrite, buffer, sizeof(buffer));
1553       if (fd != -1) {
1554         FILE* replay_data_file = os::open(fd, "w");
1555         if (replay_data_file != NULL) {
1556           fileStream replay_data_stream(replay_data_file, /*need_close=*/true);
1557           env->dump_replay_data_unsafe(&replay_data_stream);
1558           out.print_raw("#\n# Compiler replay data is saved as:\n# ");
1559           out.print_raw_cr(buffer);


   1 /*
   2  * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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  *


 131   const char *url = Arguments::java_vendor_url_bug();
 132   if (url == NULL || *url == '\0')
 133     url = JDK_Version::runtime_vendor_vm_bug_url();
 134   if (url != NULL && *url != '\0') {
 135     out->print_raw_cr("# If you would like to submit a bug report, please visit:");
 136     out->print_raw   ("#   ");
 137     out->print_raw_cr(url);
 138   }
 139   // If the crash is in native code, encourage user to submit a bug to the
 140   // provider of that code.
 141   if (thread && thread->is_Java_thread() &&
 142       !thread->is_hidden_from_external_view()) {
 143     JavaThread* jt = (JavaThread*)thread;
 144     if (jt->thread_state() == _thread_in_native) {
 145       out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug.");
 146     }
 147   }
 148   out->print_raw_cr("#");
 149 }
 150 
 151 #if INCLUDE_JFR
 152 static void print_jfr_path(outputStream *out) {
 153   if (out == NULL) {
 154     return;
 155   }
 156 
 157   const char* dump_path = Jfr::saved_emergency_dump_path();
 158   const char* repository_path = Jfr::repository_path();
 159   if ((*dump_path == '\0') &&
 160       ((repository_path == NULL) || (*repository_path == '\0'))) {
 161     return;
 162   }
 163 
 164   out->print_raw_cr("# JFR recording file will be written. Location:");
 165 
 166   if (*dump_path != '\0') {
 167     out->print_raw("# - ");
 168     out->print_raw_cr(dump_path);
 169   }
 170   if ((repository_path != NULL) && (*repository_path != '\0')) {
 171     out->print_raw("# - ");
 172     out->print_raw_cr(repository_path);
 173   }
 174 
 175   out->print_raw_cr("#");
 176 }
 177 #endif
 178 
 179 bool VMError::coredump_status;
 180 char VMError::coredump_message[O_BUFLEN];
 181 
 182 void VMError::record_coredump_status(const char* message, bool status) {
 183   coredump_status = status;
 184   strncpy(coredump_message, message, sizeof(coredump_message));
 185   coredump_message[sizeof(coredump_message)-1] = 0;
 186 }
 187 
 188 // Return a string to describe the error
 189 char* VMError::error_string(char* buf, int buflen) {
 190   char signame_buf[64];
 191   const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf));
 192 
 193   if (signame) {
 194     jio_snprintf(buf, buflen,
 195                  "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT,
 196                  signame, _id, _pc,
 197                  os::current_process_id(), os::current_thread_id());
 198   } else if (_filename != NULL && _lineno > 0) {


 629        frame fr = os::fetch_frame_from_context(_context);
 630        fr.print_on_error(st, buf, sizeof(buf));
 631        st->cr();
 632        st->print_cr("#");
 633      }
 634 
 635   STEP("printing core file information")
 636     st->print("# ");
 637     if (CreateCoredumpOnCrash) {
 638       if (coredump_status) {
 639         st->print("Core dump will be written. Default location: %s", coredump_message);
 640       } else {
 641         st->print("No core dump will be written. %s", coredump_message);
 642       }
 643     } else {
 644       st->print("CreateCoredumpOnCrash turned off, no core file dumped");
 645     }
 646     st->cr();
 647     st->print_cr("#");
 648 
 649 #if INCLUDE_JFR
 650   STEP("printing jfr repository")
 651      if (_verbose) {
 652        print_jfr_path(st);
 653      }
 654 #endif
 655 
 656   STEP("printing bug submit message")
 657 
 658      if (should_report_bug(_id) && _verbose) {
 659        print_bug_submit_message(st, _thread);
 660      }
 661 
 662   STEP("printing summary")
 663 
 664      if (_verbose) {
 665        st->cr();
 666        st->print_cr("---------------  S U M M A R Y ------------");
 667        st->cr();
 668      }
 669 
 670   STEP("printing VM option summary")
 671 
 672      if (_verbose) {
 673        // VM options
 674        Arguments::print_summary_on(st);
 675        st->cr();


1422 
1423     reporting_started();
1424     if (!TestUnresponsiveErrorHandler) {
1425       // Record reporting_start_time unless we're running the
1426       // TestUnresponsiveErrorHandler test. For that test we record
1427       // reporting_start_time at the beginning of the test.
1428       record_reporting_start_time();
1429     } else {
1430       out.print_raw_cr("Delaying recording reporting_start_time for TestUnresponsiveErrorHandler.");
1431     }
1432 
1433     if (ShowMessageBoxOnError || PauseAtExit) {
1434       show_message_box(buffer, sizeof(buffer));
1435 
1436       // User has asked JVM to abort. Reset ShowMessageBoxOnError so the
1437       // WatcherThread can kill JVM if the error handler hangs.
1438       ShowMessageBoxOnError = false;
1439     }
1440 
1441     os::check_dump_limit(buffer, sizeof(buffer));
1442     JFR_ONLY(Jfr::setup_emergency_dump_file_descriptor();)
1443 
1444     // reset signal handlers or exception filter; make sure recursive crashes
1445     // are handled properly.
1446     reset_signal_handlers();
1447 
1448     EventShutdown e;
1449     if (e.should_commit()) {
1450       e.set_reason("VM Error");
1451       e.commit();
1452     }
1453 


1454   } else {
1455     // If UseOsErrorReporting we call this for each level of the call stack
1456     // while searching for the exception handler.  Only the first level needs
1457     // to be reported.
1458     if (UseOSErrorReporting && log_done) return;
1459 
1460     // This is not the first error, see if it happened in a different thread
1461     // or in the same thread during error reporting.
1462     if (_first_error_tid != mytid) {
1463       char msgbuf[64];
1464       jio_snprintf(msgbuf, sizeof(msgbuf),
1465                    "[thread " INTX_FORMAT " also had an error]",
1466                    mytid);
1467       out.print_raw_cr(msgbuf);
1468 
1469       // error reporting is not MT-safe, block current thread
1470       os::infinite_sleep();
1471 
1472     } else {
1473       if (recursive_error_count++ > 30) {


1554         } else {
1555           out.print_raw_cr("# Can not save log file, dump to screen..");
1556           fd_log = 1;
1557         }
1558       }
1559       log.set_fd(fd_log);
1560     }
1561 
1562     report(&log, true);
1563     log_done = true;
1564     _current_step = 0;
1565     _current_step_info = "";
1566 
1567     if (fd_log > 3) {
1568       close(fd_log);
1569       fd_log = -1;
1570     }
1571 
1572     log.set_fd(-1);
1573   }
1574 
1575   JFR_ONLY(Jfr::on_vm_shutdown(true);)
1576 
1577   if (PrintNMTStatistics) {
1578     fdStream fds(fd_out);
1579     MemTracker::final_report(&fds);
1580   }
1581 
1582   static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay
1583   if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) {
1584     skip_replay = true;
1585     ciEnv* env = ciEnv::current();
1586     if (env != NULL) {
1587       const bool overwrite = false; // We do not overwrite an existing replay file.
1588       int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", overwrite, buffer, sizeof(buffer));
1589       if (fd != -1) {
1590         FILE* replay_data_file = os::open(fd, "w");
1591         if (replay_data_file != NULL) {
1592           fileStream replay_data_stream(replay_data_file, /*need_close=*/true);
1593           env->dump_replay_data_unsafe(&replay_data_stream);
1594           out.print_raw("#\n# Compiler replay data is saved as:\n# ");
1595           out.print_raw_cr(buffer);


< prev index next >