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

Gaëlle Guimezanes ggu at quartetfs.com
Thu Sep 18 06:38:59 EDT 2014


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140918/42abd171/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hs_err_pid7210.log
Type: application/octet-stream
Size: 33906 bytes
Desc: not available
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140918/42abd171/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hs_err_pid5480.log
Type: application/octet-stream
Size: 16917 bytes
Desc: not available
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140918/42abd171/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DirectMemoryCrash.java
Type: application/octet-stream
Size: 4672 bytes
Desc: not available
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140918/42abd171/attachment-0005.obj>


More information about the Concurrency-interest mailing list