changeset 4244:606aa0fc3944

8007147: Trace event ExecuteVMOperation may get dangling pointer Reviewed-by: dholmes, sla
author mgronlun
date Mon, 25 Feb 2013 10:21:50 +0100
parents a398781bfe8b
children 6bd965cc1563
files src/share/vm/runtime/vmThread.cpp src/share/vm/trace/trace.xml
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/vmThread.cpp	Thu Feb 21 07:50:48 2013 -0500
+++ b/src/share/vm/runtime/vmThread.cpp	Mon Feb 25 10:21:50 2013 +0100
@@ -383,10 +383,14 @@
     op->evaluate();
 
     if (event.should_commit()) {
+      bool is_concurrent = op->evaluate_concurrently();
       event.set_operation(op->type());
       event.set_safepoint(op->evaluate_at_safepoint());
-      event.set_blocking(!op->evaluate_concurrently());
-      event.set_caller(op->calling_thread()->osthread()->thread_id());
+      event.set_blocking(!is_concurrent);
+      // Only write caller thread information for non-concurrent vm operations.
+      // For concurrent vm operations, the thread id is set to 0 indicating thread is unknown.
+      // This is because the caller thread could have exited already.
+      event.set_caller(is_concurrent ? 0 : op->calling_thread()->osthread()->thread_id());
       event.commit();
     }
 
--- a/src/share/vm/trace/trace.xml	Thu Feb 21 07:50:48 2013 -0500
+++ b/src/share/vm/trace/trace.xml	Mon Feb 25 10:21:50 2013 +0100
@@ -283,7 +283,7 @@
       <value type="VMOPERATIONTYPE" field="operation" label="Operation" />
       <value type="BOOLEAN" field="safepoint" label="At Safepoint" description="If the operation occured at a safepoint."/>
       <value type="BOOLEAN" field="blocking" label="Caller Blocked" description="If the calling thread was blocked until the operation was complete."/>
-      <value type="OSTHREAD" field="caller" label="Caller" transition="TO"/>
+      <value type="OSTHREAD" field="caller" label="Caller" transition="TO" description="Thread requesting operation. If non-blocking, will be set to 0 indicating thread is unknown."/>
     </event>
 
   </events>