fix: exclude jdk.jfr classes from transformation to prevent JFR reentrancy corruption#821
Open
korniltsev-grafanista-yolo-vibecoder239 wants to merge 1 commit intoalibaba:masterfrom
Conversation
…rancy corruption During JFR event writing (e.g. FileWriteEvent), EventWriter.endEvent() may trigger class loading of jdk.jfr.internal.Bits on the large-size path. TtlTransformer intercepts this class loading, and Javassist introspection side effects (NotFoundException, object allocations) produce nested JFR events that corrupt the in-progress event buffer, resulting in corrupted JFR files with invalid event sizes. Adding jdk.jfr to the package exclusion list prevents this reentrancy. TTL would never transform JFR classes anyway (they are not executors or thread pools), so this is a safe no-op filter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
jdk.jfrpackage (and sub-packages) fromTtlTransformerclass transformationttl-agent) and v2-compatible modulesProblem
When JFR (Java Flight Recorder) is active,
TtlTransformercan cause reentrancy corruption in JFR'sEventWriter, producing corrupted.jfrfiles with invalid event sizes.The reentrancy chain:
FileOutputStream.write()triggers aFileWriteEventJFR eventEventWriter.endEvent()callsBits.putInt()(large-size path, events >= 128 bytes)jdk.jfr.internal.BitstriggersClassFileTransformer.transform()TtlTransformerintercepts, Javassist introspects the class viagetDeclaredMethod()NotFoundException("run(..) is not found in jdk.jfr.internal.Bits")JavaExceptionThrow,ObjectAllocationOutsideTLAB)FileWriteEvent.jfrfileStack trace from corrupted JFR file
The following
jdk.JavaExceptionThrowevent was found embedded inside a corrupted event, showing TTL's transformer being invoked during JFR event writing:After this event, an
ObjectAllocationOutsideTLABevent is also embedded in the remaining bytes, followed by corruption:Fix
Add
jdk.jfrto the existing package exclusion list inTtlTransformer.transform(), alongside the existingcom.alibaba.ttlandjava.langexclusions.This is safe because TTL only transforms executor/thread-pool classes — JFR classes would never be transformed anyway. The filter simply avoids the Javassist introspection side effects that trigger the reentrancy.
Test plan