Concurrency problem with the double check locking pattern

4 messages Options
Embed this post
Permalink
jlouvel

Concurrency problem with the double check locking pattern

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Hi guys,

 

Ivan Gorgiev came across a subtle multi-threading issue as described here:

 

“Synchronization issues with Template”

http://restlet.tigris.org/issues/show_bug.cgi?id=881

 

It appears that the “double-check locking” pattern that we use in many places in Restlet code doesn’t work reliably in some environments (AMD-64 in his case).

 

He further points to this web page which worries me:

 

“The "Double-Checked Locking is Broken" Declaration”

http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

 

I’d like to get the opinion of concurrency experts in this list to see if we better synchronize all those lazy creation methods instead?

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~
http://www.noelios.com

 

 

Tim Peierls

Re: Concurrency problem with the double check locking pattern

Reply Threaded More More options
Print post
Permalink
What that paper says is that the double-checked locking idiom *as commonly applied* is broken. See a more recent description of the correct use of double-checked locking, including a discussion of when it is appropriate, in Effective Java, 2nd edition.

AFAIK, the Restlet codebase is doing things correctly, but I could have missed something. If you have a specific case that appears to be broken, let me know.

--tim

On Fri, Sep 25, 2009 at 6:30 AM, Jerome Louvel <[hidden email]> wrote:

Hi guys,

 

Ivan Gorgiev came across a subtle multi-threading issue as described here:

 

“Synchronization issues with Template”

http://restlet.tigris.org/issues/show_bug.cgi?id=881

 

It appears that the “double-check locking” pattern that we use in many places in Restlet code doesn’t work reliably in some environments (AMD-64 in his case).

 

He further points to this web page which worries me:

 

“The "Double-Checked Locking is Broken" Declaration”

http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

 

I’d like to get the opinion of concurrency experts in this list to see if we better synchronize all those lazy creation methods instead?

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~
http://www.noelios.com

 

 


Tim Peierls

Re: Concurrency problem with the double check locking pattern

Reply Threaded More More options
Print post
Permalink
I'll take a close look at Template.java when I get back from vacation.

On Fri, Sep 25, 2009 at 2:52 PM, Tim Peierls <[hidden email]> wrote:
What that paper says is that the double-checked locking idiom *as commonly applied* is broken. See a more recent description of the correct use of double-checked locking, including a discussion of when it is appropriate, in Effective Java, 2nd edition.

AFAIK, the Restlet codebase is doing things correctly, but I could have missed something. If you have a specific case that appears to be broken, let me know.

--tim


On Fri, Sep 25, 2009 at 6:30 AM, Jerome Louvel <[hidden email]> wrote:

Hi guys,

 

Ivan Gorgiev came across a subtle multi-threading issue as described here:

 

“Synchronization issues with Template”

http://restlet.tigris.org/issues/show_bug.cgi?id=881

 

It appears that the “double-check locking” pattern that we use in many places in Restlet code doesn’t work reliably in some environments (AMD-64 in his case).

 

He further points to this web page which worries me:

 

“The "Double-Checked Locking is Broken" Declaration”

http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

 

I’d like to get the opinion of concurrency experts in this list to see if we better synchronize all those lazy creation methods instead?

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~
http://www.noelios.com

 

 



jlouvel

RE: Concurrency problem with the double check locking pattern

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Hi Tim,

 

Thanks for looking into this when you have a chance. But no worry during your vacation! :-)

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~
http://www.noelios.com

 

 

 

De : [hidden email] [mailto:[hidden email]] De la part de Tim Peierls
Envoyé : dimanche 27 septembre 2009 13:44
À : [hidden email]
Objet : Re: Concurrency problem with the double check locking pattern

 

I'll take a close look at Template.java when I get back from vacation.

On Fri, Sep 25, 2009 at 2:52 PM, Tim Peierls <[hidden email]> wrote:

What that paper says is that the double-checked locking idiom *as commonly applied* is broken. See a more recent description of the correct use of double-checked locking, including a discussion of when it is appropriate, in Effective Java, 2nd edition.

 

AFAIK, the Restlet codebase is doing things correctly, but I could have missed something. If you have a specific case that appears to be broken, let me know.

 

--tim

 

On Fri, Sep 25, 2009 at 6:30 AM, Jerome Louvel <[hidden email]> wrote:

Hi guys,

Ivan Gorgiev came across a subtle multi-threading issue as described here:

Synchronization issues with Template

http://restlet.tigris.org/issues/show_bug.cgi?id=881

It appears that the double-check locking pattern that we use in many places in Restlet code doesnt work reliably in some environments (AMD-64 in his case).

He further points to this web page which worries me:

The "Double-Checked Locking is Broken" Declaration

http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

Id like to get the opinion of concurrency experts in this list to see if we better synchronize all those lazy creation methods instead?

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder~
http://www.noelios.com