JDK-8058744 : Crash in C1 OSRed method w/ Unsafe usage
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8u40,9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-09-18
  • Updated: 2017-08-10
  • Resolved: 2014-09-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40Fixed 9 b34Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
http://cs.oswego.edu/pipermail/concurrency-interest/2014-September/012953.html
Date: 	Thu, 18 Sep 2014 12:38:59 +0200
From: 	Ga��lle Guimezanes <ggu@quartetfs.com>
To: 	concurrency-interest@cs.oswego.edu

[...]

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.

[...]

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fec9130336a, pid=228310, tid=140654375552768
#
# JRE version: OpenJDK Runtime Environment (9.0) (build 1.9.0-internal-debug-vlivanov_2014_09_18_07_56-b00)
# Java VM: OpenJDK 64-Bit Server VM (1.9.0-internal-debug-vlivanov_2014_09_18_07_56-b00 mixed mode linux-amd64 compressed oops)
# Problematic frame: 
# J 270% C1 DirectMemoryCrash.alternateBitsUsingBytes(I)V (181 bytes) @ 0x00007fec9130336a [0x00007fec91302d00+0x66a]
#

ILW = HLH = P2
I = H = crash w/ product binaries
L = L = problematic code shape involves Unsafe usage
W = H = no workaround is known
Comments
Test output from one of the runs right before the crash: iteration 0 reading 0 at address 140037947676144 [...] iteration 60414 reading 42 at address 140037947683695 iteration 60414 putting 42 at address 140037947683695 iteration 60415 reading 42 at address 140037947683695 iteration 60415 putting -86 at address 140037947683695 140037947676144 == 0x7F5D202055F0 140037947683695 == 0x7F5D2020736F Crash occurs at: 0x00007f5d10ea75ea: movsbl 0x0(%r13,%rcx,8),%r14d si_signo: 11 (SIGSEGV), si_code: 2 (SEGV_ACCERR), si_addr: 0x00007f5d2027b5f0 R13=0x00007f5d202055f0 (base) RCX=0x000000000000ec00 == 60416 (index)
18-09-2014

Relevant code in the test: long byteAddress = addressAndLength[0] + (i >>> 3); byte oldValue = unsafe.getByte(byteAddress); i = 60416 addressAndLength[0] = 0x7f5d202055f0 Correct address to read from: 0x7f5d20207370 The instruction used to compute address is incorrect: 0x00007f5d10ea75ea: movsbl 0x0(%r13,%rcx,8),%r14d
18-09-2014

Instructions: (pc=0x00007f8c9115a576) 0x00007f8c9115a556: 00 00 4c 8b 48 10 48 8b cb c1 e9 03 48 63 c9 49 0x00007f8c9115a566: 03 c9 48 89 8c 24 a8 00 00 00 48 3b 06 4c 63 db 0x00007f8c9115a576: 47 0f be 1c d9 49 bd 98 0b a0 6c 07 00 00 00 45 0x00007f8c9115a586: 8b 6d 64 49 c1 e5 03 4c 89 ac 24 e0 00 00 00 48 4c8b4810 mov r9,QWORD PTR [rax+0x10] 488bcb mov rcx,rbx c1e903 shr ecx,0x3 4863c9 movsxd rcx,ecx 4903c9 add rcx,r9 48898c24a8000000 mov QWORD PTR [rsp+0xa8],rcx 483b06 cmp rax,QWORD PTR [rsi] 4c63db movsxd r11,ebx ==> 470fbe1cd9 movsx r11d,BYTE PTR [r9+r11*8] siginfo: si_signo: 11 (SIGSEGV), si_code: 2 (SEGV_ACCERR), si_addr: 0x00007f8ca0153f30 R9 =0x00007f8ca00dbeb0 is an unknown value R11=0x000000000000f010 is an unknown value 49bd980ba06c07000000 movabs r13,0x76ca00b98 458b6d64 mov r13d,DWORD PTR [r13+0x64] 49c1e503 shl r13,0x3 4c89ac24e0000000 mov QWORD PTR [rsp+0xe0],r13
18-09-2014