[concurrency-interest] a volatile bug?

Aleksey Shipilev aleksey.shipilev at gmail.com
Wed May 16 15:08:39 EDT 2012


Aha, now I realize how come it is reproduced on Windows. java launcher
selects -client for Windows machines.

I was able to reproduce it with -client on my i5, Linux i686:

$  ~/Install/jdk7u4/bin/java -version
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) Server VM (build 23.0-b21, mixed mode)

$  ~/Install/jdk7u4/bin/java -server Test
[empty]

$  ~/Install/jdk7u4/bin/java -client -version
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) Client VM (build 23.0-b21, mixed mode)

$  ~/Install/jdk7u4/bin/java -client Test
error x 100

Holy macaroni, is this a bug in C1?
Digging more.

-Aleksey.

On Wed, May 16, 2012 at 10:57 PM, R.A. Porter <coyotesqrl at gmail.com> wrote:
> I was able to duplicate this with two different versions of the HotSpot
> client on my Windows 7 box:
> 1.6.0_31
> and
> 1.6.0_14
>
> -r
>
> On Wed, May 16, 2012 at 11:40 AM, Boehm, Hans <hans.boehm at hp.com> wrote:
>>
>> > From: Pavel Rappo
>> >
>> > If you see some concurrent behaviour that violates JMM then what else
>> > could that be?
>> A JDK bug AND a serious test suite omission?
>>
>> But is the problem real?  Can it be reproduced on a mainstream JVM?
>>
>> Note that the example in the original posting also read b before the loop,
>> so naïve common subexpression elimination would cause the bug.  Hopefully
>> nobody does CSE in cases like this.
>>
>> Hans
>> >
>> > On 16 May 2012, at 20:55, Zhong Yu wrote:
>> >
>> > > as reported on
>> > > http://stackoverflow.com/questions/10620680
>> > >
>> > > basically there are
>> > >
>> > >    volatile int a;
>> > >    int b;
>> > >
>> > > Thread 1:
>> > >
>> > >    b=1;
>> > >    a=1;
>> > >
>> > > Thread 2:
>> > >
>> > >    while(a==0)
>> > >        ;
>> > >    if(b==0)
>> > >        print("error");
>> > >
>> > > "error" is seen printed on 32 bit JDK6 on 64bit machine
>> > > _______________________________________________
>> > > 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
>>
>> _______________________________________________
>> 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
>



More information about the Concurrency-interest mailing list