< prev index next >

src/hotspot/share/utilities/vmError.cpp

Print this page
rev 53272 : [mq]: 8214975-no-hs-errfile-on-early-assert
rev 53273 : [mq]: 8214975-no-hs-errfile-on-early-assert-delta1

@@ -1297,22 +1297,23 @@
   // Do not rely on it being preserved across function calls.
   static char buffer[O_BUFLEN];
 
   // File descriptor to tty to print an error summary to.
   // Hard wired to stdout; see JDK-8215004 (compatibility concerns).
-  static const int fd_out = 1;
+  static const int fd_out = 1; // stdout
 
   // File descriptor to the error log file.
   static int fd_log = -1;
 
   // Use local fdStream objects only. Do not use global instances whose initialization
   // relies on dynamic initialization (see JDK-8214975). Do not rely on these instances
   // to carry over into recursions or invocations from other threads.
   fdStream out(fd_out);
   out.set_scratch_buffer(buffer, sizeof(buffer));
 
-  fdStream log(fd_log); // May or may not be open at this point.
+  // Depending on the re-entrance depth at this point, fd_log may be -1 or point to an open hs-err file.
+  fdStream log(fd_log);
   log.set_scratch_buffer(buffer, sizeof(buffer));
 
   // How many errors occurred in error handler when reporting first_error.
   static int recursive_error_count;
 

@@ -1471,15 +1472,15 @@
     report(&log, true);
     log_done = true;
     _current_step = 0;
     _current_step_info = "";
 
-    if (fd_log != fd_out) {
+    if (fd_log != -1) {
       close(fd_log);
+      fd_log = -1;
     }
 
-    fd_log = -1;
     log.set_fd(-1);
   }
 
   static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay
   if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) {
< prev index next >