JDK-8247247 : JFR tests fail due to JDK-8235521 missing doPrivileged block
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jfr
  • Affected Version: 15
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-06-09
  • Updated: 2020-07-15
  • Resolved: 2020-06-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15 JDK 16
15 b28Fixed 16Fixed
Related Reports
Relates :  
Description
The following tests fail in the JDK15 CI:

jdk/jfr/api/consumer/security/TestRecordingStream.java
jdk/jfr/api/consumer/security/TestStreamingLocal.java
jdk/jfr/jmx/security/TestEnoughPermission.java
jdk/jfr/jmx/security/TestNotificationListenerPermission.java

Here's a snippet from the TestRecordingStream.java log file:

#section:main
----------messages:(5/375)----------
command: main jdk.jfr.api.consumer.security.TestStreamingLocal
reason: User specified action: run main/othervm/secure=java.lang.SecurityManager/java.security.policy=local-streaming.policy jdk.jfr.api.consumer.security.TestStreamingLocal 
Mode: othervm [/othervm specified]
Additional options from @modules: --add-modules jdk.jfr,java.management
elapsed time (seconds): 4.367
----------configuration:(3/51)----------
Boot Layer
  add modules: jdk.jfr java.management

----------System.out:(1/140)----------
[1.670s][warning][jfr,system] Could not initialize JDK events. access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
----------System.err:(4/204)----------

Exception: java.lang.StackOverflowError thrown from the UncaughtExceptionHandler in thread "MainThread"

Exception: java.lang.StackOverflowError thrown from the UncaughtExceptionHandler in thread "main"
----------rerun:(41/6121)*----------

It appears that these test failures are related to the push
for the following bug:

    JDK-8235521 Replacement API for Unsafe::ensureClassInitialized
Comments
Changeset: c0475c81 Author: Mandy Chung <mchung@openjdk.org> Date: 2020-06-11 11:07:09 +0000 URL: https://git.openjdk.java.net/lanai/commit/c0475c81
02-07-2020

Changeset: 6dec50a7 Author: Mandy Chung <mchung@openjdk.org> Date: 2020-06-11 11:07:09 +0000 URL: https://git.openjdk.java.net/lanai/commit/6dec50a7
02-07-2020

Changeset: c0475c81 Author: Mandy Chung <mchung@openjdk.org> Date: 2020-06-11 11:07:09 +0000 URL: https://git.openjdk.java.net/amber/commit/c0475c81
02-07-2020

URL: https://hg.openjdk.java.net/jdk/jdk15/rev/1242c6a84642 User: dcubed Date: 2020-06-11 21:28:00 +0000
11-06-2020

Proposed fix: http://cr.openjdk.java.net/~mchung/jdk15/webrevs/8247247/webrev.00/ I think only registering an event class needs to ensure the event class being initialized. It's already called with doPrivileged block. public static void registerEvent(Class<? extends jdk.internal.event.Event> eventClass) { doPrivileged(() -> MetadataRepository.getInstance().register(eventClass), new FlightRecorderPermission(Utils.REGISTER_EVENT)); } Since MetadataRepository::getEventType checks if the event handler is registered, this means that the event class is already initialized. I suggest SecuritySupport::getHandler to take an ensureInitialized parameter and only registerEvent calls getHandler with ensureInitialized=true. unregister does not need to ensure the class to be initialized.
11-06-2020

The JFR call to `Unsafe::ensureClassInitialized` was replaced with `MethodHandles.privateLookupIn(clazz, LOOKUP).ensureInitialized(clazz)`. The call to `MethodHandles::privateLookupIn` has an unconditional security permission check that should be wrapped by a doPrivileged call.
09-06-2020

ILW = MHH = P2
09-06-2020