JDK-8214059 : Undefined behaviour in ADLC
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8,11,12
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-11-19
  • Updated: 2019-09-04
  • Resolved: 2018-11-26
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 12 Other
11.0.3Fixed 12 b22Fixed openjdk8u212Fixed
Related Reports
Relates :  
Description
Compiling (with GCC 8.1) and running ADLC with -fsanitize=undefined
caught some issues (see log snippet below).

- There are some incorrect C-style pointer casts that happen to work.  A
pointer to Form is downcasted to OperandForm, but the actual object pointed to is of type OpClassForm. This occurs in multiple places in adlparse.cpp and formssel.cpp (there are only two instances in the log file, the rest from inspection)

- Integer overflow behaviour is relied upon to check if a sum of two
integers is greater then MAX_INT. This occurs in dfa.cpp, function Expr::compute_max(), around line 764.

Build log snippet:

$ make all
Building target 'all' in configuration 'linux-x86_64-server-release'
Compiling 8 files for BUILD_TOOLS_LANGTOOLS
Creating hotspot/variant-server/tools/adlc/adlc from 13 file(s)
Compiling 2 files for BUILD_JVMTI_TOOLS
Compiling 1 files for BUILD_JFR_TOOLS
Parsing 2 properties into enum-like class for jdk.compiler
Compiling 13 properties into resource bundles for jdk.javadoc
Compiling 19 properties into resource bundles for jdk.compiler
Compiling 12 properties into resource bundles for jdk.jdeps
Compiling 7 properties into resource bundles for jdk.jshell
Compiling 117 files for BUILD_java.compiler.interim
Compiling 396 files for BUILD_jdk.compiler.interim
/home/stooke/dev/openjdk/jdk12/src/hotspot/share/adlc/adlparse.cpp:2873:64: runtime error: downcast of address 0x00000252a880 which does not point to anobject of type 'OperandForm'
0x00000252a880: note: object is of type 'OpClassForm'
 00 00 00 00  d0 64 59 00 00 00 00 00  02 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'OpClassForm'
/home/stooke/dev/openjdk/jdk12/src/hotspot/share/adlc/formssel.cpp:922:57: runtime error: downcast of address 0x00000252a880 which does not point to an object of type 'OperandForm'
0x00000252a880: note: object is of type 'OpClassForm'
 00 00 00 00  d0 64 59 00 00 00 00 00  02 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'OpClassForm'
/home/stooke/dev/openjdk/jdk12/src/hotspot/share/adlc/dfa.cpp:767:7: runtime error: signed integer overflow: 2147483647 + 150 cannot be represented in type 'int'
Creating support/modules_libs/java.base/server/libjvm.so from 862 file(s)
Creating hotspot/variant-server/libjvm/gtest/libjvm.so from 103 file(s)
Creating hotspot/variant-server/libjvm/gtest/gtestLauncher from 1 file(s)
Compiling 304 files for BUILD_jdk.javadoc.interim
Compiling 160 files for BUILD_TOOLS_JDK
Comments
8u RFA: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-February/008525.html
07-02-2019

Fix Request Backporting this patch allows to compile jdk11 with modern compilers without exposing us to UB bugs. The patch applies cleanly, builds Linux x86_64 cleanly, passes hotspot/tier1 cleanly.
07-12-2018

Review thread: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2018-November/031456.html
20-11-2018

Assigned this issue to me on behalf of Simon Tooke.
19-11-2018