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