JDK-8219151 : Illegal instruction exception on JDK 12 due to incorrect CPU feature bits
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 12
  • Priority: P1
  • Status: Resolved
  • Resolution: Fixed
  • CPU: x86
  • Submitted: 2019-02-16
  • Updated: 2019-08-15
  • Resolved: 2019-02-19
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 12 JDK 13
12 b33Fixed 13Fixed
Related Reports
Relates :  
Description
The VNNI optimizations patch (JDK-8214751) inadvertently sets the VPCLMULQDQ cpu feature bit even on platforms where VPCLMULQDQ is not available. 
When the java.util.zip CRC32 update intrinsics kick in, it then uses the VPCLMULQDQ instruction which results in illegal instruction exception as below:
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x00007f1324b7b9bc, pid=81841, tid=81842
#
# JRE version: OpenJDK Runtime Environment (12.0+32) (build 12+32)
# Java VM: OpenJDK 64-Bit Server VM (12+32, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# v  ~StubRoutines::updateBytesCRC32
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

The following line in vm_version_x86.hpp is the cause :
#define CPU_VNNI ((uint64_t)UCONST64(0x16000000000))��
The above mask ends up setting three bits instead of a single bit, one of which happens to be the VPCLMULQDQ bit.


Comments
Fix request approved. I think the fix is safe and as Hotspot Group lead I agree to push this fix into JDK 12.
19-02-2019

Testing finished. Testing tier1-hs-tier3 on all platforms passed clean. Testing on avx512 machine (Skylake) showed several failures which are not related. Most of them were OOM when run with ZGC. 2 were Graal related. 1 was ClassNotFound. And last one was due to JDK-8163511. Based on this I think testing for changes passed.
19-02-2019

The issue was observed while running SPECjbb2015 on the Intel platform that supports VNNI but does not support VPCLMULQDQ.
16-02-2019

Fix Request Issue: The VNNI feature setting mask ends up setting three bits instead of a single bit, one of which happens to be the VPCLMULQDQ bit. This causes the compiler to generate VPCLMULQDQ instruction on platforms even where it is not supported thus causing illegal instruction exception. Nature of fix: The fix is to correct the mask for VNNI feature to set only 1 bit. It is a one line change. The following line in vm_version_x86.hpp is the cause: #define CPU_VNNI ((uint64_t)UCONST64(0x16000000000)) // Vector Neural Network Instructions The line should be changed to: #define CPU_VNNI ((uint64_t)UCONST64(0x10000000000)) // Vector Neural Network Instructions Test coverage: With the webrev the failed test passes on Intel platforms which support VNNI but does not support VPCLMULQDQ. Changeset: The JDK12 webrev is at : http://cr.openjdk.java.net/~sviswanathan/8219151/webrev.00/
16-02-2019