[concurrency-interest] Make the double-checked lock idiom broken on x86

Mohan Radhakrishnan radhakrishnan.mohan at gmail.com
Mon May 8 05:07:55 EDT 2017


Hi,

How about a JCStress test ?

Something like
http://hg.openjdk.java.net/code-tools/jcstress/file/9cbe23132d16/jcstress-samples/src/main/java/org/openjdk/jcstress/samples/JMMSample_03_Coherence.java


Mohan

On 8 May 2017 at 14:25, Alex Otenko <oleksandr.otenko at gmail.com> wrote:

> I’d start with using the same version and brand of the JVM Bill used at
> the time of writing the article, which was probably written over 15 years
> ago.
>
> Alex
>
> > On 8 May 2017, at 15:22, Yubin Ruan <ablacktshirt at gmail.com> wrote:
> >
> > Hi, from Bill Pugh's website[1] I read that the double-checked lock
> idiom is
> > broken. Bill Pugh gave an example:
> >
> >    // Broken multithreaded version
> >    // "Double-Checked Locking" idiom
> >    class Foo {
> >      private Helper helper = null;
> >      public Helper getHelper() {
> >        if (helper == null)
> >          synchronized(this) {
> >            if (helper == null)
> >              helper = new Helper();
> >        }
> >        return helper;
> >      }
> >      // other functions and members...
> >    }
> >
> > His analysis is convincing, but the code he gave[2] work *well* on x86.
> > That is expected to break sometimes. But, running it from time to time,
> > I never see it break.
> >
> > How to verify that the double-check lock idiom will break on x86?
> >
> > ---
> > Yubin
> >
> > [1]: https://www.cs.umd.edu/~pugh/java/memoryModel/
> DoubleCheckedLocking.html
> > [2]: https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckTest.java
> > _______________________________________________
> > Concurrency-interest mailing list
> > Concurrency-interest at cs.oswego.edu
> > http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20170508/b9e0f690/attachment.html>


More information about the Concurrency-interest mailing list