JDK-8047290 : Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-06-18
  • Updated: 2015-06-03
  • Resolved: 2014-12-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b45Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
When locking with MutexLockerEx(SOMELOCK, Mutex::_no_safepoint_check_flag) if some other code locks without Mutex::_no_safepoint_check_flag, the JVM will deadlock.   The JVM should have some check that prevents you from doing this.  From email discussion:

On 6/17/14, 6:11 AM, Mikael Gerdin wrote:
> I wish there was a consistency check though.  If you take a lock without
> checking for safepoint, we should give an assertion if you take the same
> lock and check for safepoint.  Not sure if there's an easy way to code
> it, but I think it would be worth having.

Can't we use the type system for this?

Have a
class NoSafepointCheckMutex which always elides safepoint checks 
and a
class Mutex which does not allow elision of safepoint checks.

/Mikael

Comments
Also from email: Relatedly every block of code that takes a lock without a safepoint check should have a NO_SAFEPOINT_VERIFIER. I wonder if that can be built in to the lock_without_safepoint_check?
19-06-2014

Found Markus' bug: JDK-8039458 Ensure consistency of Monitor/Mutex lock acquisitions in relation to safepoint protocol
18-06-2014

I posted the following on that e-mail thread: > If you take a lock without checking for safepoint, we should give > an assertion if you take the same lock and check for safepoint. > Not sure if there's an easy way to code it, but I think it would > be worth having. Markus G has been working on some code that does this. Not sure where he is on that adventure. Dan
18-06-2014