[concurrency-interest] JVM crash when using Unsafe to read/write bytes in Java 8 (no crash with same code in Java 7)

David Holmes davidcholmes at aapt.net.au
Fri Sep 19 00:52:40 EDT 2014


Gaelle had already submitted a webbug that came through as 8058781, so I
closed that as a dup of Vladimir's bug.

David

> -----Original Message-----
> From: concurrency-interest-bounces at cs.oswego.edu
> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Vladimir
> Ivanov
> Sent: Friday, 19 September 2014 1:21 AM
> To: Vitaly Davidovich; Gaëlle Guimezanes
> Cc: hotspot compiler; Concurrency-interest at cs.oswego.edu
> Subject: Re: [concurrency-interest] JVM crash when using Unsafe to
> read/write bytes in Java 8 (no crash with same code in Java 7)
>
>
> FYI, I filed JDK-8058744 [1] to track that.
>
> Best regards,
> Vladimir Ivanov
>
> [1] https://bugs.openjdk.java.net/browse/JDK-8058744
>
> On 9/18/14, 6:51 PM, Vitaly Davidovich wrote:
> > Sounds like it.  Given you have a self-contained repro, you can forward
> > this email thread (or CC them) to hotspot-compiler-dev at openjdk.java.net
> > <mailto:hotspot-compiler-dev at openjdk.java.net>, and see if anyone from
> > the JIT team has any ideas.
> >
> > On Thu, Sep 18, 2014 at 10:49 AM, Gaëlle Guimezanes <ggu at quartetfs.com
> > <mailto:ggu at quartetfs.com>> wrote:
> >
> >     We're nearing it down... disabling OSR compilation or tiered
> >     compilation makes the test run correctly.
> >     So if the options work as I understood, this means the problem is in
> >     C1, only when doing OSR.
> >
> >     On Thu, Sep 18, 2014 at 4:17 PM, Vitaly Davidovich
> >     <vitalyd at gmail.com <mailto:vitalyd at gmail.com>> wrote:
> >
> >         Try turning off tiered compilation (-XX:-TieredCompilation) and
> >         pass -server to the launcher.  I *think* that should do it.
> >
> >         However, I think you ran this with C1 just without OSR
> >         compilation (I believe -Xcomp would do that), so this seems to
> >         point at an OSR compile.  You can try disabling OSR compilation
> >         (irrespective of C1 or C2): -XX:-UseOnStackReplacement
> >
> >         On Thu, Sep 18, 2014 at 9:54 AM, Gaëlle Guimezanes
> >         <ggu at quartetfs.com <mailto:ggu at quartetfs.com>> wrote:
> >
> >             Running the test class with -Xint or -Xcomp makes the test
> >             work with no crash, so the problem apparently is with OSR
> >             compiles...
> >
> >             However I don't know how to use only the C2 compiler, can
> >             you explain how to do it?
> >
> >             Thanks
> >             Gaelle
> >
> >
> >
> >             On Thu, Sep 18, 2014 at 2:53 PM, Vitaly Davidovich
> >             <vitalyd at gmail.com <mailto:vitalyd at gmail.com>> wrote:
> >
> >                 Looks like it's C1 OSR compiled code when it crashes.
> >                 Have you tried running this only in interpreter and only
> >                 using C2 compiler? Can also try disabling OSR compiles.
> >                 Just to rule out any miscompilation ...
> >
> >                 Sent from my phone
> >
> >                 On Sep 18, 2014 8:09 AM, "Gaëlle Guimezanes"
> >                 <ggu at quartetfs.com <mailto:ggu at quartetfs.com>> wrote:
> >
> >                     Hi Stanimir,
> >
> >                     Thanks for the suggestion, but I've tried allocating
> >                     extra 16 bytes and even extra 1024 bytes, and it
> >                     still fails.
> >
> >                     Gaelle
> >
> >                     On Thu, Sep 18, 2014 at 1:34 PM, Stanimir Simeonoff
> >                     <stanimir at riflexo.com <mailto:stanimir at riflexo.com>>
> >                     wrote:
> >
> >                         Hi,
> >
> >                         I suppose the problem occurs due to the last few
> >                         (less than 8) bytes are addressed. Probably
> >                         getByte(address) won't read just a byte but a
> >                         32/64 word and mask+shift it.
> >                         Try to allocate extra 16 bytes instead of 8.
> >
> >                         Stanimir
> >
> >                         On Thu, Sep 18, 2014 at 1:38 PM, Gaëlle
> >                         Guimezanes <ggu at quartetfs.com
> >                         <mailto:ggu at quartetfs.com>> wrote:
> >
> >                             Hello,
> >
> >                             I am sorry this is not really a concurrency
> >                             problem since it can be reproduced using
> >                             only one thread, but I didn't really know
> >                             where to discuss this. Since many of you use
> >                             Unsafe I thought you might be able to help
> >                             me understand what's happening or direct me
> >                             to the correct mailing list.
> >
> >                             I have a strange behaviour using Unsafe in
> >                             Java 1.8.0_20.
> >                             When I use getByte/putByte to manipulate
> >                             bits, my JVM crashes (access violation).
> >                             But when I use getLong/putLong for the same
> >                             purpose it works correctly (even though I
> >                             have allocated exactly the same amount of
> >                             memory).
> >                             Also, when using Java 1.7.0_67 to compile
> >                             and run the same source code, both the
> >                             getByte/putByte and the getLong/putLong
> >                             approaches work correctly.
> >
> >                             I have attached a simple test class
> >                             (DirectMemoryCrash.java) for reproducing the
> >                             problem: you can run it with no argument for
> >                             the getByte/putByte version, or with
> >                             "useLongs" arguments for
> >                             the getLong/putLong version.
> >
> >                             I also have attached crash reports :
> >                             hs_err_pid5480.log for the crash on windows
> >                             hs_err_pid7210.log for the crash on linux
> >
> >                             Thank you for your attention,
> >                             Best regards,
> >                             Gaëlle Guimezanes.
> >
> >
> >
> _______________________________________________
> >                             Concurrency-interest mailing list
> >                             Concurrency-interest at cs.oswego.edu
> >                             <mailto:Concurrency-interest at cs.oswego.edu>
> >
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
> >
> >
> >
> >                     _______________________________________________
> >                     Concurrency-interest mailing list
> >                     Concurrency-interest at cs.oswego.edu
> >                     <mailto: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