RFR: 8132306: java/lang/ref/ReferenceEnqueue.java fails with "RuntimeException: Error: poll() returned null; expected ref object"

Peter Levart peter.levart at gmail.com
Thu Jul 30 08:46:41 UTC 2015



On 07/30/2015 10:38 AM, Peter Levart wrote:
>> [This suggests the r.queue = NULL assignment in reallyPoll() should be
>> moved later, though I think the assignment order in reallyPoll()
>> doesn't matter.]
>
> I think the assignment to r.queue = NULL in realyPoll() should be 
> moved *before* the assignment to 'head' (which might assign null if 
> 'r' was the last element). Here's why:
>
> Suppose we have a Reference 'r' and it's associated ReferenceQueue 
> 'q'. Currently it can happen that the following evaluates to true, 
> which is surprising:
>
> q.poll() == null && r.isEnqueued()
>
>
> Regards, Peter 

Well, the above condition is not very representative of the situation 
I'm trying to describe. It can be perfectly legal when racing with 
enqueueing of the Reference 'r'. But when racing with de-queueing (i.e. 
poll()) it is surprising. So let me re-phrase the expression which is 
always surprising when it evaluates to true:

r.isEnqueued() && q.poll() == null && r.isEnqueued()

Regards, Peter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-gc-dev/attachments/20150730/2e31e166/attachment.htm>


More information about the hotspot-gc-dev mailing list