JDK-8224828 : aarch64: rflags is not correct after safepoint poll
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8-aarch64,11,13
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: aarch64
  • Submitted: 2019-05-27
  • Updated: 2021-02-01
  • Resolved: 2019-05-30
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 11 JDK 13 JDK 14 Other
11.0.4Fixed 13 b24Fixed 14Fixed openjdk8u292Fixed
Related Reports
Relates :  
Description
Currently, the rflags register is not handled in push_CPU_state and pop_CPU_state for the aarch64 port.  
This is causing random Hadoop Terasort failure using a aarch64-8u jvm.
After some investigation, we located the problematic C2 JIT code snippet:

1204   0x0000ffff785f8a3c: cmp       w14, #0x0
1205   0x0000ffff785f8a40: adrp      x11, 0x0000ffff88830000
1206                                                 ;   {poll}
1207   0x0000ffff785f8a44: mov       w17, w20        ; OopMap{r17=NarrowOop [32]=Oop [40]=Oop [56]=Oop [64]=Oop [80]=NarrowOop off=1224}
1208                                                 ;*ifeq
1209                                                 ; - org.apache.hadoop.util.PriorityQueue::downHeap@121 (line 149)
1210                                                 ; - org.apache.hadoop.util.PriorityQueue::adjustTop@1 (line 108)
1211                                                 ; - org.apache.hadoop.mapred.Merger$MergeQueue::adjustPriorityQueue@59 (line 595)
1212                                                 ; - org.apache.hadoop.mapred.Merger$MergeQueue::next@25 (line 618)
1213
1214   0x0000ffff785f8a48: ldr       wzr, [x11]      ;   {poll}
1215   0x0000ffff785f8a4c: csel      w24, w12, w10, lt  ;*invokevirtual compareTo
1216                                                 ; - org.apache.hadoop.io.FastByteComparisons$LexicographicalComparerHolder$UnsafeComparer::compareTo@16 (     line 132)
1217                                                 ; - org.apache.hadoop.io.FastByteComparisons::compareTo@11 (line 46)
1218                                                 ; - org.apache.hadoop.io.WritableComparator::compareBytes@8 (line 188)
1219                                                 ; - org.apache.hadoop.io.Text$Comparator::compare@39 (line 368)
1220                                                 ; - org.apache.hadoop.mapred.Merger$MergeQueue::lessThan@70 (line 658)
1221                                                 ; - org.apache.hadoop.util.PriorityQueue::downHeap@41 (line 141)
1222                                                 ; - org.apache.hadoop.util.PriorityQueue::adjustTop@1 (line 108)
1223                                                 ; - org.apache.hadoop.mapred.Merger$MergeQueue::adjustPriorityQueue@59 (line 595)
1224                                                 ; - org.apache.hadoop.mapred.Merger$MergeQueue::next@25 (line 618)

At line 1204, the rflags register is defined and it will be used at line 1215.  There is a safepoint poll in between at line 1214.  
Safepoint is requested at line 1214 and the control flow continues in the code generated by SafepointBlob* SharedRuntime::generate_handler_blob
This blob calls save_live_register and restore_live_registers which will finally calls push_CPU_state and pop_CPU_state.
As the rflags register is not saved and restored by push_CPU_state and pop_CPU_state, we see an invalid rflags at line 1215.
Comments
jdk8u-fix-request is not necessary for aarch64/jdk8u-shenandoah. Please just post a review to the aarch64-port-dev mailing list.
30-05-2019

The Java method in which the bug was triggered: org.apache.hadoop.mapred.Merger$MergeQueue::next()Z For this method, I also attached the source code and complete erroneous C2 JIT code. Merger.java -- Java source code for the method MergeQueue_next.C2.asm -- Erroneous C2 JIT code for the method
28-05-2019

attached please find proposed patch for jdk13. This should be backported to jdk11 and aarch64 jdk8u.
27-05-2019