changeset 8965:80ee2541504e

8145788: JVM crashes with -XX:+EnableTracing Summary: Events can trigger before ResourceMark is usable: move use from writeEvent() to print_val(). Reviewed-by: dholmes, ysuenaga, mlarsson
author phh
date Thu, 23 Aug 2018 22:56:32 +0000
parents 2af8917ffbee
children 16b9bbfaa450
files src/share/vm/trace/traceEventClasses.xsl src/share/vm/trace/traceStream.hpp
diffstat 2 files changed, 5 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/trace/traceEventClasses.xsl	Thu Aug 16 23:50:43 2018 -0400
+++ b/src/share/vm/trace/traceEventClasses.xsl	Thu Aug 23 22:56:32 2018 +0000
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
- Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
 // Some parts of traceEvent.hpp are used outside of
 // INCLUDE_TRACE
 
-#include "memory/resourceArea.hpp"
 #include "tracefiles/traceTypes.hpp"
 #include "trace/traceEvent.hpp"
 #include "utilities/macros.hpp"
@@ -135,7 +134,6 @@
 </xsl:text>
   <xsl:value-of select="concat('  Event', @id, '(EventStartTime timing=TIMED) : TraceEvent&lt;Event', @id, '&gt;(timing) {}', $newline)"/>
   void writeEvent(void) {
-    ResourceMark rm;
     if (UseLockedTracing) {
       ttyLocker lock;
       writeEventContent();
--- a/src/share/vm/trace/traceStream.hpp	Thu Aug 16 23:50:43 2018 -0400
+++ b/src/share/vm/trace/traceStream.hpp	Thu Aug 23 22:56:32 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 
 #include "utilities/macros.hpp"
 #if INCLUDE_TRACE
+#include "memory/resourceArea.hpp"
 #include "oops/klass.hpp"
 #include "oops/method.hpp"
 #include "oops/symbol.hpp"
@@ -79,11 +80,8 @@
     _st.print("%s = %f", label, val);
   }
 
-  // Caller is machine generated code located in traceEventClasses.hpp
-  // Event<TraceId>::writeEvent() (pseudocode) contains the
-  // necessary ResourceMark for the resource allocations below.
-  // See traceEventClasses.xsl for details.
   void print_val(const char* label, const Klass* const val) {
+    ResourceMark rm;
     const char* description = "NULL";
     if (val != NULL) {
       Symbol* name = val->name();
@@ -94,11 +92,8 @@
     _st.print("%s = %s", label, description);
   }
 
-  // Caller is machine generated code located in traceEventClasses.hpp
-  // Event<TraceId>::writeEvent() (pseudocode) contains the
-  // necessary ResourceMark for the resource allocations below.
-  // See traceEventClasses.xsl for details.
   void print_val(const char* label, const Method* const val) {
+    ResourceMark rm;
     const char* description = "NULL";
     if (val != NULL) {
       description = val->name_and_sig_as_C_string();