< prev index next >

src/hotspot/share/utilities/vmError.cpp

Print this page
rev 56552 : imported patch 8218543-2


1188 
1189   os::print_cpu_info(st, buf, sizeof(buf));
1190   st->cr();
1191 
1192   // STEP("printing memory info")
1193 
1194   os::print_memory_info(st);
1195   st->cr();
1196 
1197   // STEP("printing internal vm info")
1198 
1199   st->print_cr("vm_info: %s", VM_Version::internal_vm_info_string());
1200   st->cr();
1201 
1202   // print a defined marker to show that error handling finished correctly.
1203   // STEP("printing end marker")
1204 
1205   st->print_cr("END.");
1206 }
1207 
1208 volatile intptr_t VMError::first_error_tid = -1;
1209 
1210 /** Expand a pattern into a buffer starting at pos and open a file using constructed path */
1211 static int expand_and_open(const char* pattern, bool overwrite_existing, char* buf, size_t buflen, size_t pos) {
1212   int fd = -1;
1213   int mode = O_RDWR | O_CREAT;
1214   if (overwrite_existing) {
1215     mode |= O_TRUNC;
1216   } else {
1217     mode |= O_EXCL;
1218   }
1219   if (Arguments::copy_expand_pid(pattern, strlen(pattern), &buf[pos], buflen - pos)) {
1220     fd = open(buf, mode, 0666);
1221   }
1222   return fd;
1223 }
1224 
1225 /**
1226  * Construct file name for a log file and return it's file descriptor.
1227  * Name and location depends on pattern, default_pattern params and access
1228  * permissions.


1338   // to carry over into recursions or invocations from other threads.
1339   fdStream out(fd_out);
1340   out.set_scratch_buffer(buffer, sizeof(buffer));
1341 
1342   // Depending on the re-entrance depth at this point, fd_log may be -1 or point to an open hs-err file.
1343   fdStream log(fd_log);
1344   log.set_scratch_buffer(buffer, sizeof(buffer));
1345 
1346   // How many errors occurred in error handler when reporting first_error.
1347   static int recursive_error_count;
1348 
1349   // We will first print a brief message to standard out (verbose = false),
1350   // then save detailed information in log file (verbose = true).
1351   static bool out_done = false;         // done printing to standard out
1352   static bool log_done = false;         // done saving error log
1353 
1354   if (SuppressFatalErrorMessage) {
1355       os::abort(CreateCoredumpOnCrash);
1356   }
1357   intptr_t mytid = os::current_thread_id();
1358   if (first_error_tid == -1 &&
1359       Atomic::cmpxchg(mytid, &first_error_tid, (intptr_t)-1) == -1) {
1360 
1361     // Initialize time stamps to use the same base.
1362     out.time_stamp().update_to(1);
1363     log.time_stamp().update_to(1);
1364 
1365     _id = id;
1366     _message = message;
1367     _thread = thread;
1368     _pc = pc;
1369     _siginfo = siginfo;
1370     _context = context;
1371     _filename = filename;
1372     _lineno = lineno;
1373     _size = size;
1374     jio_vsnprintf(_detail_msg, sizeof(_detail_msg), detail_fmt, detail_args);
1375 
1376     // first time
1377     _error_reported = true;
1378 
1379     reporting_started();


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




1188 
1189   os::print_cpu_info(st, buf, sizeof(buf));
1190   st->cr();
1191 
1192   // STEP("printing memory info")
1193 
1194   os::print_memory_info(st);
1195   st->cr();
1196 
1197   // STEP("printing internal vm info")
1198 
1199   st->print_cr("vm_info: %s", VM_Version::internal_vm_info_string());
1200   st->cr();
1201 
1202   // print a defined marker to show that error handling finished correctly.
1203   // STEP("printing end marker")
1204 
1205   st->print_cr("END.");
1206 }
1207 
1208 volatile intptr_t VMError::_first_error_tid = -1;
1209 
1210 /** Expand a pattern into a buffer starting at pos and open a file using constructed path */
1211 static int expand_and_open(const char* pattern, bool overwrite_existing, char* buf, size_t buflen, size_t pos) {
1212   int fd = -1;
1213   int mode = O_RDWR | O_CREAT;
1214   if (overwrite_existing) {
1215     mode |= O_TRUNC;
1216   } else {
1217     mode |= O_EXCL;
1218   }
1219   if (Arguments::copy_expand_pid(pattern, strlen(pattern), &buf[pos], buflen - pos)) {
1220     fd = open(buf, mode, 0666);
1221   }
1222   return fd;
1223 }
1224 
1225 /**
1226  * Construct file name for a log file and return it's file descriptor.
1227  * Name and location depends on pattern, default_pattern params and access
1228  * permissions.


1338   // to carry over into recursions or invocations from other threads.
1339   fdStream out(fd_out);
1340   out.set_scratch_buffer(buffer, sizeof(buffer));
1341 
1342   // Depending on the re-entrance depth at this point, fd_log may be -1 or point to an open hs-err file.
1343   fdStream log(fd_log);
1344   log.set_scratch_buffer(buffer, sizeof(buffer));
1345 
1346   // How many errors occurred in error handler when reporting first_error.
1347   static int recursive_error_count;
1348 
1349   // We will first print a brief message to standard out (verbose = false),
1350   // then save detailed information in log file (verbose = true).
1351   static bool out_done = false;         // done printing to standard out
1352   static bool log_done = false;         // done saving error log
1353 
1354   if (SuppressFatalErrorMessage) {
1355       os::abort(CreateCoredumpOnCrash);
1356   }
1357   intptr_t mytid = os::current_thread_id();
1358   if (_first_error_tid == -1 &&
1359       Atomic::cmpxchg(mytid, &_first_error_tid, (intptr_t)-1) == -1) {
1360 
1361     // Initialize time stamps to use the same base.
1362     out.time_stamp().update_to(1);
1363     log.time_stamp().update_to(1);
1364 
1365     _id = id;
1366     _message = message;
1367     _thread = thread;
1368     _pc = pc;
1369     _siginfo = siginfo;
1370     _context = context;
1371     _filename = filename;
1372     _lineno = lineno;
1373     _size = size;
1374     jio_vsnprintf(_detail_msg, sizeof(_detail_msg), detail_fmt, detail_args);
1375 
1376     // first time
1377     _error_reported = true;
1378 
1379     reporting_started();


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


< prev index next >