RFR: JDK-8303069: Memory leak in CompilerOracle::parse_from_line

Damon Fenacci duke at openjdk.org
Thu Mar 16 15:17:06 UTC 2023


A memory leak has been detected using *lsan* when running the `compiler/blackhole/BlackholeExperimentalUnlockTest.java` test.

This happens when parsing the *blackhole* *CompileCommand*. There is a check for the `-XX:+UnlockExperimentalVMOptions` flag being enabled when *blackhole* is used. If this flag is not set, a warning gets printed and the *CompileCommand* is not taken.

Unfortunately this happens in `register_commands` where commands are supposed to be added to a list. In this case we bail out and the option is neither added nor deleted.

https://github.com/openjdk/jdk/blob/f629152021d4ce0288119c47d5a111b87dce1de6/src/hotspot/share/compiler/compilerOracle.cpp#L310-L313

So, this changes deletes the `matcher` object before returning. This is done in `register_commands` (the callee) mainly because a couple of other similar checks are also done in this function.

The other option would have been to move the check to the caller (the only one for this case) before `register_command`:
https://github.com/openjdk/jdk/blob/f629152021d4ce0288119c47d5a111b87dce1de6/src/hotspot/share/compiler/compilerOracle.cpp#L915-L917
but it seemed less appropriate (no other similar checks).

Letting it handle like other experimental flags (code below) is not an option either since in this case we have to do with a `CompileCommand`.
https://github.com/openjdk/jdk/blob/f629152021d4ce0288119c47d5a111b87dce1de6/src/hotspot/share/runtime/flags/jvmFlag.cpp#L112-L118

-------------

Commit messages:
 - JDK-8303069: Memory leak in CompilerOracle::parse_from_line

Changes: https://git.openjdk.org/jdk/pull/13060/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13060&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8303069
  Stats: 2 lines in 1 file changed: 2 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/13060.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/13060/head:pull/13060

PR: https://git.openjdk.org/jdk/pull/13060


More information about the hotspot-compiler-dev mailing list