JDK-8207913 : OpenJDK8 crashes with -XX:+EnableTracing
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 8u172
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2018-07-19
  • Updated: 2018-08-24
  • Resolved: 2018-08-24
Related Reports
Duplicate :  
Description
Reported by Xin Liu (xxinliu@amazon.com).

If you invoke java with the option -XX:+EnableTracing, it will crash immediately. It's because events XXXFlagChanged doesn't work in the initial thread. 

class EventBooleanFlagChanged : public TraceEvent<EventBooleanFlagChanged>
  EventBooleanFlagChanged(EventStartTime timing=TIMED) : TraceEvent<EventBooleanFlagChanged>(timing) {}

  void writeEvent(void) {
    ResourceMark rm;
    if (UseLockedTracing) {
      ttyLocker lock;
      writeEventContent();
    } else {
      writeEventContent();
    }
  }
};

The ResourceMark won't work if Thread::current() is NULL.

A simple patch for OpenJDK follows, but won't work for OracleJDK.

diff --git a/src/hotspot/src/share/vm/runtime/globals.cpp b/src/hotspot/src/share/vm/runtime/globals.cpp
index 310fc2ea..6f89c275 100644
--- a/src/hotspot/src/share/vm/runtime/globals.cpp
+++ b/src/hotspot/src/share/vm/runtime/globals.cpp
@@ -608,12 +608,12 @@ bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) {
 template<class E, class T>
 static void trace_flag_changed(const char* name, const T old_value, const T new_value, const Flag::Flags origin)
 {
-  E e;
-  e.set_name(name);
-  e.set_old_value(old_value);
-  e.set_new_value(new_value);
-  e.set_origin(origin);
-  e.commit();
+  //E e;
+  //e.set_name(name);
+  //e.set_old_value(old_value);
+  //e.set_new_value(new_value);
+  //e.set_origin(origin);
+  //e.commit();
 }
 
 bool CommandLineFlags::boolAt(const char* name, size_t len, bool* value) {

Comments
Closing out as a duplicate. When pushing the fix, please use 8145788 as bug id in your changeset comment!
24-08-2018

Looks to be a duplicate of JDK-8145788.
21-08-2018

s@ubuntu:~/dev$ ~/bin/jdk1.8.0_181/bin/java -version java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode) s@ubuntu:~/dev$ ~/bin/jdk1.8.0_181/bin/java -XX:+EnableTracing HelloWorld Hello, World s@ubuntu:~/dev$ /usr/bin/java -version openjdk version "1.8.0_171" OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11) OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode) s@ubuntu:~/dev$ /usr/bin/java -XX:+EnableTracing HelloWorld Segmentation fault (core dumped) Reproduced.
20-07-2018