RFR(S): 8173743: Failures during class definition can lead to memory leaks in metaspace
coleen.phillimore at oracle.com
Tue Feb 7 00:18:37 UTC 2017
Volker, This looks really good. Thank you for fixing this! I can't
see any risk to jdk9 so I think this seems fine to check in now, even
though it's been a bug since jdk8.
I guess you can check this in yourself with the demo-submit tool?
Otherwise, I will sponsor it.
On 2/6/17 1:40 PM, Volker Simonis wrote:
> can somebody please review the following change:
> It fixes some problems during class definitions where instance klasses
> can leak into the metaspace in cases where the class definition fails
> after the class was successfully loaded from the bytecode stream.
> There are actually two cases to consider:
> 1. If we load the same class several times into the same class loader,
> we will get LinkageErrors after the first successful load. But
> nevertheless we will first construct a new instanceKlass for each new
> load attempt and this instanceKlass will never be deleted.
> 2. If we have a parallel capable class loader, set
> -XX:-UnsyncloadClass and/or -XX:+AllowParallelDefineClass and load a
> class from several threads at the same time in parallel, it can happen
> that we create several instance klasses for the same class. At the end
> only one of them will be added to the system dictionary, but all the
> other ones will never be deleted. Notice that if we run this scenario
> without setting either of -XX:-UnsyncloadClass or
> -XX:+AllowParallelDefineClass, this scenario will degrade into the
> case above and we will get LinkageErrors for all but the first
> successful load.
> The change comes with a regression test which checks for the two cases
> just describe and also for the failing class redefinition case, which
> currently doesn't produce a memory leak.
> I've already committed this to the hs-demo-submit/hotspot/ forest and
> it went through without a problem. So in theory it should have passed
> the internal JPRT tests although I'm not sure if the test set of the
> "demo-submit" forest and the real hotspot repo are exactly the same
> (CC'ed Tim and Brian).
> Thank you and best regards,
More information about the hotspot-runtime-dev