RFR: 8246442: nmethod::can_convert_to_zombie() asserts when not called by the sweeper

David Holmes david.holmes at oracle.com
Wed Jun 3 11:40:08 UTC 2020


Hi Erik,

LGTM.

Your explanation and solution seems entirely reasonable.

Thanks,
David

On 3/06/2020 9:26 pm, Erik Österlund wrote:
> Hi,
> 
> nmethod::can_convert_to_zombie() used to be called only by the sweeper, 
> after it has checked that
> an nmethod is not entrant. Due to the single call site, there was an 
> assert checking that the nmethod
> should be not entrant (the condition just checked).
> However, it is now used in nmethod::post_compiled_method_load_event(), 
> where the result of the assert is racy.
> 
> When an nmethod is created, the load event will never be able to see the 
> nmethod spuriously flipping
> to zombie, because there simply are no safepoint polls/transitions 
> between the nmethod being created
> and the load event firing. However, the jvmti_GenerateEvents can observe 
> such spurious flips to zombie.
> It is completely harmless, because the whole operation runs under the 
> CodeCache_lock, which prevents
> further nmethods from being flushed. But they can flip to zombie, which 
> is indeed exactly what the
> check is design to test. Therefore, this is just a false positive 
> assertion failure.
> 
> Proposed fix: make the assert only apply when called from the sweeper 
> thread.
> 
> Webrev:
> http://cr.openjdk.java.net/~eosterlund/8246442/webrev.00/
> 
> Bug:
> https://bugs.openjdk.java.net/browse/JDK-8246442
> 
> Thanks,
> /Erik


More information about the hotspot-dev mailing list