[8u] RFR 8252904: VM crashes when JFR is used and JFR event class is transformed

Andrey Petushkov andrey at azul.com
Tue Sep 8 11:23:55 UTC 2020


Dear All,

Please consider the following fix to avoid crash when JFR event class is
transformed upon load. The problem is caused by using stale reference to
ClassFileStream which is created (conditionally if the class is
transformed by JVMTI hook) under ResourceMark in
ClassFileParser.parseClassFile(). This dead reference is leaked into
caller code, where it is accessed by JFR itself.

There is no such problem in jdk11 and above because class loading
implementation is completely different and JVMTI hook responsible for
transformation is invoked by KlassFactory, not ClassFileParser.
Moreover, in jdk11 it's KlassFactory (analog of
ClassLoader/SystemDictionary in a sense that it's the caller of
ClassFileParser is responsible for placing ResourceMark, just like
proposed patch does for jdk8u code)

The problem can easily be reproduced on slowdebug build with a test
which transforms jdk.jfr.Event class or it's subclasses. In this
scenario VM crashes immediately when JFR is activated because
ResourceMark destructor clears the freed memory.

Webrev is here https://cr.openjdk.java.net/~apetushkov/8252904/

Thanks,
Andrey



More information about the jdk8u-dev mailing list