Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public class SmapEntryFactory {
private static final SmapEntryCache SMAP_ENTRY_CACHE = new SmapEntryCache(Duration.ofMillis(500));

static {
// Load JFR Handlers class early, if present (it has been moved and renamed in JDK23+).
// This prevents a deadlock. See PROF-13025.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Is there a JDK bug id as well to drop here ?

The deadlock has been reported to upstream, and a fix has been proposed there

try {
Class.forName("jdk.jfr.events.Handlers");
Copy link
Copy Markdown
Contributor

@jbachorik jbachorik Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are touching this class only when we have JFR available, so loading the Handlers class should not be disturbing anything.
But - we have smap entry events disabled by default, yet we are getting these issues ... I have a suspicion that we are initing the support regardless of the enablement status. Could you check for PROFILING_SMAP_COLLECTION_ENABLED setting before merging this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be slighly more complex. The smap event is registered in datadog.trace.bootstrap.Agent and there we probably don't have easy access to PROFILING_SMAP_COLLECTION_ENABLED (not sure), and it might also affect other events. I filed PROF-13213 for a deeper investigation. I would merge this PR as-is. Is that ok?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

} catch (Exception e) {
// Ignore when the class is not found or anything else goes wrong.
}

if (!JavaVirtualMachine.isJ9() && !JavaVirtualMachine.isOracleJDK8()) {
SMAP_ENTRY_EVENT_TYPE = EventType.getEventType(SmapEntryEvent.class);
AGGREGATED_SMAP_ENTRY_EVENT_TYPE = EventType.getEventType(AggregatedSmapEntryEvent.class);
Expand Down