From a66be7b90e87d9b70b2dcf0b5c02e588825bb794 Mon Sep 17 00:00:00 2001 From: thartmann Date: Wed, 26 Nov 2014 08:06:58 +0100 Subject: [PATCH] 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 | 2 +- src/share/vm/compiler/compileLog.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/share/vm/compiler/compileBroker.cpp b/src/share/vm/compiler/compileBroker.cpp index 6edb5c5b6..dad99ec0e 100644 --- a/src/share/vm/compiler/compileBroker.cpp +++ b/src/share/vm/compiler/compileBroker.cpp @@ -1845,7 +1845,7 @@ void CompileBroker::init_compiler_thread_log() { os::file_separator(), thread_id, os::current_process_id()); } - fp = fopen(file_name, "at"); + fp = fopen(file_name, "wt"); if (fp != NULL) { if (LogCompilation && Verbose) { tty->print_cr("Opening compilation log %s", file_name); diff --git a/src/share/vm/compiler/compileLog.cpp b/src/share/vm/compiler/compileLog.cpp index 9def25c08..0637fd04f 100644 --- a/src/share/vm/compiler/compileLog.cpp +++ b/src/share/vm/compiler/compileLog.cpp @@ -55,8 +55,10 @@ CompileLog::CompileLog(const char* file_name, FILE* fp, intx thread_id) } CompileLog::~CompileLog() { - delete _out; + delete _out; // Close fd in fileStream::~fileStream() _out = NULL; + // Remove partial file after merging in CompileLog::finish_log_on_error + unlink(_file); FREE_C_HEAP_ARRAY(char, _identities, mtCompiler); FREE_C_HEAP_ARRAY(char, _file, mtCompiler); } @@ -268,10 +270,9 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen) } file->print_raw_cr(""); close(partial_fd); - unlink(partial_file); } CompileLog* next_log = log->_next; - delete log; + delete log; // Removes partial file log = next_log; } _first = NULL; -- GitLab