On Fri, 8 Jul 2022 11:44:53 GMT, Doug Lea <d...@openjdk.org> wrote:

> 8066859 : java/lang/ref/OOMEInReferenceHandler.java failed with 
> java.lang.Exception: Reference Handler thread died

src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
 line 296:

> 294:         byte spins = 0, postSpins = 0;   // retries upon unpark of first 
> thread
> 295:         boolean interrupted = false, first = false;
> 296:         Node pred = null, t;             // predecessor of node when 
> enqueued

Nit: please don't use this style of multi-variable declaration as they are very 
easy to mis-read. Also the comment only applies to one of the variables.

src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
 line 1626:

> 1624:             }
> 1625:             if (!isHeldExclusively() || !release(savedState = 
> getState()))
> 1626:                 throw LockSupport.staticIllegalMonitorStateException; 
> // OOM

How is it possible to get IMSE this deep into the code? And the comment is 
confusing - OOM?

src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java line 
463:

> 461:      *  Preallocated exceptions thrown if acquiring or releasing locks
> 462:      *  when OutOfMemory.
> 463:      */

I don't see why this should be necessary. IMSE is thrown before any state 
changes occur and so it is is fine if the IMSE is replaced by OOME.

Even IE should be safe at the points it is thrown.

Also in both cases you want to see a full and proper stacktrace.

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

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

Reply via email to