[concurrency-interest] Question about final field semantic in case of a race

Thomas Krieger thomas.krieger at vmlens.com
Thu Aug 31 06:20:39 EDT 2017


It is ARMv7: uname -a

Linux raspberrypi 4.4.11-v7+ #888 SMP Mon May 23 20:10:33 BST 2016 armv7l GNU/Linux

The JVM is rather new:

java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)

It is an Oracle JVM (jdk-8-oracle-arm32-vfp-hflt)


Thanks,

Thomas Krieger


> 
>     On 31 August 2017 at 11:40 Aleksey Shipilev <shade at redhat.com> wrote:
> 
>     On 08/31/2017 11:17 AM, Thomas Krieger wrote:
> 
>         > > 
> >         I am running the following JCStressTest on a Raspberry Pi 3 with a Java(TM) SE Runtime Environment
> >         (build 1.8.0_65-b17) Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode):
> > 
> >         @JCStressTest
> >         @Outcome(id = "0", expect = Expect.ACCEPTABLE, desc = "Default outcome.")
> >         @State
> >         public class BigDecimalToString {
> >         private final BigDecimal testBigDecimal = new BigDecimal("0.56");
> >         @Actor
> >         public void actor1(IntResult1 r) {
> >         testBigDecimal.toString().length();
> >         }
> >         @Actor
> >         public void actor2(IntResult1 r) {
> >         testBigDecimal.toString().length();
> >         }
> >         }
> > 
> >         In about half of the iterations, I see the following Exception:> java.lang.NullPointerException
> > 
> >     > 
>     ...
> 
>         > > 
> >         Or, because of the final field, all threads should have only seen an
> >         initialized value?
> > 
> >     > 
>     String is published by race, but String.value is final, so it should be safe. Seeing NPE on
>     dereferencing String.value is weird, and probably points to a compiler bug. Run with more modern
>     JDK?. It is also not clear if you run ARMv7 or AArch64 VM (not all RPi 3 distros are 64-bit, and
>     many identify RPi 3 as 32-bit ARM).
> 
>     Thanks,
>     -Aleksey
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20170831/2d54ec1c/attachment.html>


More information about the Concurrency-interest mailing list