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

Damon Fenacci duke at openjdk.org
Fri Mar 17 13:07:44 UTC 2023


On Thu, 16 Mar 2023 15:03:52 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

>> 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
>
> Looks good to me.

Thanks a lot @TobiHartmann @jcking for your reviews!

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

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


More information about the hotspot-compiler-dev mailing list