RFR 8049220: URL.factory data race

Paul Sandoz paul.sandoz at oracle.com
Fri Jul 4 14:54:30 UTC 2014


On Jul 3, 2014, at 6:33 PM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> On 03/07/2014 09:43, Peter Levart wrote:
>> Hi,
>> 
>> I noticed a data race in java.net.URL:
>> 
>>    https://bugs.openjdk.java.net/browse/JDK-8049220
>> 
>> I propose the following simple patch:
>> 
>> http://cr.openjdk.java.net/~plevart/jdk9-dev/URL.factory/webrev.01/
>> 
> A good catch and the change looks good to me.  

Yes, well spotted. May i suggest that the following comment is updated:

1109             factory = fac; // volatile write

to say something about ensuring safe publication of a constructed handle? since it is often quite tricky to reason about why a volatile write is needed (to stamp in, at least, a StoreStore barrier).

For JMM v9 we may not need to mark such a ref as volatile.


> I assume it just wasn't noticed because it can only be set once and probably rared used too.
> 

Yeah, i wonder whether it would ever get optimized/inlined to the point at which re-ordering could practically happen.

Paul.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.openjdk.java.net/pipermail/net-dev/attachments/20140704/9bcac6eb/signature.asc>


More information about the net-dev mailing list