Mon, 01 Jul 2013 09:13:19 +0000
7060111: race condition in VMError::report_and_die()
Reviewed-by: zgu, coleenp
Contributed-by: volker.simonis@gmail.com
src/share/vm/utilities/vmError.cpp | file | annotate | diff | comparison | revisions | |
src/share/vm/utilities/vmError.hpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/utilities/vmError.cpp Sun Jun 30 09:59:08 2013 -0400 1.2 +++ b/src/share/vm/utilities/vmError.cpp Mon Jul 01 09:13:19 2013 +0000 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -799,6 +799,14 @@ 1.11 VMError* volatile VMError::first_error = NULL; 1.12 volatile jlong VMError::first_error_tid = -1; 1.13 1.14 +// An error could happen before tty is initialized or after it has been 1.15 +// destroyed. Here we use a very simple unbuffered fdStream for printing. 1.16 +// Only out.print_raw() and out.print_raw_cr() should be used, as other 1.17 +// printing methods need to allocate large buffer on stack. To format a 1.18 +// string, use jio_snprintf() with a static buffer or use staticBufferStream. 1.19 +fdStream VMError::out(defaultStream::output_fd()); 1.20 +fdStream VMError::log; // error log used by VMError::report_and_die() 1.21 + 1.22 /** Expand a pattern into a buffer starting at pos and open a file using constructed path */ 1.23 static int expand_and_open(const char* pattern, char* buf, size_t buflen, size_t pos) { 1.24 int fd = -1; 1.25 @@ -853,13 +861,6 @@ 1.26 // Don't allocate large buffer on stack 1.27 static char buffer[O_BUFLEN]; 1.28 1.29 - // An error could happen before tty is initialized or after it has been 1.30 - // destroyed. Here we use a very simple unbuffered fdStream for printing. 1.31 - // Only out.print_raw() and out.print_raw_cr() should be used, as other 1.32 - // printing methods need to allocate large buffer on stack. To format a 1.33 - // string, use jio_snprintf() with a static buffer or use staticBufferStream. 1.34 - static fdStream out(defaultStream::output_fd()); 1.35 - 1.36 // How many errors occurred in error handler when reporting first_error. 1.37 static int recursive_error_count; 1.38 1.39 @@ -868,7 +869,6 @@ 1.40 static bool out_done = false; // done printing to standard out 1.41 static bool log_done = false; // done saving error log 1.42 static bool transmit_report_done = false; // done error reporting 1.43 - static fdStream log; // error log 1.44 1.45 // disble NMT to avoid further exception 1.46 MemTracker::shutdown(MemTracker::NMT_error_reporting);
2.1 --- a/src/share/vm/utilities/vmError.hpp Sun Jun 30 09:59:08 2013 -0400 2.2 +++ b/src/share/vm/utilities/vmError.hpp Mon Jul 01 09:13:19 2013 +0000 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -96,6 +96,9 @@ 2.11 return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR); 2.12 } 2.13 2.14 + static fdStream out; 2.15 + static fdStream log; // error log used by VMError::report_and_die() 2.16 + 2.17 public: 2.18 2.19 // Constructor for crashes