8007993: hotspot.log w/ enabled LogCompilation can be an invalid XML

Wed, 26 Nov 2014 08:06:58 +0100

author
thartmann
date
Wed, 26 Nov 2014 08:06:58 +0100
changeset 7393
ecccc23346fe
parent 7392
97f4214e9a70
child 7396
b12418b0d05c

8007993: hotspot.log w/ enabled LogCompilation can be an invalid XML
Summary: Open compilation log files in write-mode and close before deletion attempt.
Reviewed-by: vlivanov

src/share/vm/compiler/compileBroker.cpp file | annotate | diff | comparison | revisions
src/share/vm/compiler/compileLog.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/compiler/compileBroker.cpp	Mon Dec 01 09:38:52 2014 -0500
     1.2 +++ b/src/share/vm/compiler/compileBroker.cpp	Wed Nov 26 08:06:58 2014 +0100
     1.3 @@ -1845,7 +1845,7 @@
     1.4                       os::file_separator(), thread_id, os::current_process_id());
     1.5        }
     1.6  
     1.7 -      fp = fopen(file_name, "at");
     1.8 +      fp = fopen(file_name, "wt");
     1.9        if (fp != NULL) {
    1.10          if (LogCompilation && Verbose) {
    1.11            tty->print_cr("Opening compilation log %s", file_name);
     2.1 --- a/src/share/vm/compiler/compileLog.cpp	Mon Dec 01 09:38:52 2014 -0500
     2.2 +++ b/src/share/vm/compiler/compileLog.cpp	Wed Nov 26 08:06:58 2014 +0100
     2.3 @@ -55,8 +55,10 @@
     2.4  }
     2.5  
     2.6  CompileLog::~CompileLog() {
     2.7 -  delete _out;
     2.8 +  delete _out; // Close fd in fileStream::~fileStream()
     2.9    _out = NULL;
    2.10 +  // Remove partial file after merging in CompileLog::finish_log_on_error
    2.11 +  unlink(_file);
    2.12    FREE_C_HEAP_ARRAY(char, _identities, mtCompiler);
    2.13    FREE_C_HEAP_ARRAY(char, _file, mtCompiler);
    2.14  }
    2.15 @@ -268,10 +270,9 @@
    2.16        }
    2.17        file->print_raw_cr("</compilation_log>");
    2.18        close(partial_fd);
    2.19 -      unlink(partial_file);
    2.20      }
    2.21      CompileLog* next_log = log->_next;
    2.22 -    delete log;
    2.23 +    delete log; // Removes partial file
    2.24      log = next_log;
    2.25    }
    2.26    _first = NULL;

mercurial