RFR (XS): 8023037 : Race between ciEnv::register_method and nmethod::make_not_entrant_or_zombie

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Tue Nov 5 03:39:22 PST 2013


There's a race between compiler thread during method registration and 
sweeper: sweeper can invalidate a nmethod which hasn't been installed yet.

Consider the following scenario:
     - new nmethod(...)

     - invalidates newly allocated nmethod and patches VEP to call 
     - tries to unlink it, but method()->from_compiled_entry() != 
verified_entry_point() since nmethod hasn't been installed yet

     - installs already invalidated nmethod

Calling corresponding Java method will lead to infinite loop: VEP of the 
compiled method calls handle_wrong_method and call site resolution 
returns the very same compiled method.

The fix is to grab a lock after nmethod is allocated in the code cache 
and check that it hasn't been already invalidated by the sweeper before 
proceeding. Sweeper already synchronizes on a nmethod before 
invalidating it.

Testing: failing test w/ diagnostic output.


Best regards,
Vladimir Ivanov

More information about the hotspot-compiler-dev mailing list