eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.27k stars 720 forks source link

Assertion failure at omr/compiler/optimizer/OMRSimplifierHandlers.cpp:5281 with PROD_WITH_ASSUMES #17615

Open knn-k opened 1 year ago

knn-k commented 1 year ago

Assertion failure in running sanity.functional with Java 11/17 for AArch64 macOS/Linux with PROD_WITH_ASSUMES:

[2023-06-19T01:44:16.936Z] Assertion failed at /Users/jenkins/workspace/Build_JDK11_aarch64_mac_Personal/omr/compiler/optimizer/OMRSimplifierHandlers.cpp:5281: 0
[2023-06-19T01:44:16.936Z] VMState: 0x000507ff
[2023-06-19T01:44:16.936Z]  unexpected opcode provided to isReducible()
[2023-06-19T01:44:16.936Z] compiling java/net/URI$Parser.parseHierarchical(II)I at level: warm

macOS Java 11 build Linux Java 11 build macOS Java 17 build Linux Java 17 build

knn-k commented 1 year ago

This happens in the optimization phase as shown below:

_ZN2TR4trapEv+0x50 (0x0000FFFF87970870 [libj9jit29.so+0x4b0870])
_ZN2TR9assertionEPKciS1_S1_z+0x9c (0x0000FFFF87970A3C [libj9jit29.so+0x4b0a3c])
_ZN25IfxcmpgeToIfxcmpeqReducer11isReducibleEv+0x68 (0x0000FFFF87BE2F48 [libj9jit29.so+0x722f48])
_Z18ificmpgeSimplifierPN2TR4NodeEPNS_5BlockEPNS_10SimplifierE+0xcc (0x0000FFFF87BDE73C [libj9jit29.so+0x71e73c])
_ZN3OMR10Simplifier8simplifyEPN2TR4NodeEPNS1_5BlockE+0x84 (0x0000FFFF87B8FA78 [libj9jit29.so+0x6cfa78])
_ZN3OMR10Simplifier8simplifyEPN2TR7TreeTopEPNS1_5BlockE+0x64 (0x0000FFFF87B8FE78 [libj9jit29.so+0x6cfe78])
_ZN3OMR10Simplifier8simplifyEPN2TR5BlockE+0x20 (0x0000FFFF87B8FEE4 [libj9jit29.so+0x6cfee4])
_ZN3OMR10Simplifier21simplifyExtendedBlockEPN2TR7TreeTopE+0x13c (0x0000FFFF87B9007C [libj9jit29.so+0x6d007c])
_ZN3OMR10Simplifier14performOnBlockEPN2TR5BlockE+0x7c (0x0000FFFF87B904FC [libj9jit29.so+0x6d04fc])
_ZN3OMR9Optimizer19performOptimizationEPK20OptimizationStrategyiii.localalias+0x1fc4 (0x0000FFFF87B3D8C4 [libj9jit29.so+0x67d8c4])
_ZN3OMR9Optimizer8optimizeEv+0x220 (0x0000FFFF87B3DD60 [libj9jit29.so+0x67dd60])
_ZN3OMR11Compilation7compileEv+0x56c (0x0000FFFF87918A4C [libj9jit29.so+0x458a4c])
knn-k commented 1 year ago

Changing the TR_ASSERT() to a TR_ASSERT_FATAL_WITH_NODE() shows the following:

 [ERR] Assertion failed at /home/ubuntu/openj9/openj9-openjdk-jdk11/omr/compiler/optimizer/OMRSimplifierHandlers.cpp:5281: 0
 [ERR] VMState: 0x000507ff
 [ERR]  Node 0xffff3308b270 [ificmpne]: unexpected opcode provided to isReducible()
 [ERR] compiling java/net/URI$Parser.parseHierarchical(II)I at level: warm

 [ERR] Node context:
 [ERR]
 [ERR] ...
 [ERR] n623n     ificmpne --> block_30 BBStart at n595n ()                                           [    0xffff3308b270] bci=[2,26,3016] rc=0 vc=1483 vn=- li=- udi=- nc=2 flg=0x20
 [ERR] n2176n      ior                                                                               [    0xffff332697e0] bci=[2,23,3016] rc=1 vc=0 vn=- li=- udi=- nc=2
 [ERR] n1476n        icmpeq                                                                          [    0xffff3317bd10] bci=[2,23,3016] rc=1 vc=1483 vn=- li=- udi=- nc=2
 [ERR] n613n           ==>icall
 [ERR] n1475n          iconst 47 (X!=0 X>=0 )                                                        [    0xffff3317bcc0] bci=[2,23,3016] rc=1 vc=1483 vn=- li=- udi=- nc=0 flg=0x104
 [ERR] n2171n        ior                                                                             [    0xffff33269650] bci=[2,23,3016] rc=1 vc=0 vn=- li=- udi=- nc=2
 [ERR] n1472n          icmpeq                                                                        [    0xffff3317bbd0] bci=[2,23,3016] rc=1 vc=1483 vn=- li=- udi=- nc=2
 [ERR] n613n             ==>icall
 [ERR] n1471n            iconst 63 (X!=0 X>=0 )                                                      [    0xffff3317bb80] bci=[2,23,3016] rc=1 vc=1483 vn=- li=- udi=- nc=0 flg=0x104
 [ERR] n1468n          icmpeq                                                                        [    0xffff3317ba90] bci=[2,23,3016] rc=1 vc=1483 vn=- li=- udi=- nc=2
 [ERR] n613n             ==>icall
 [ERR] n1467n            iconst 35 (X!=0 X>=0 )                                                      [    0xffff3317ba40] bci=[2,23,3016] rc=1 vc=1483 vn=- li=- udi=- nc=0 flg=0x104
 [ERR] n2167n      iconst 0 (X==0 X>=0 X<=0 )                                                        [    0xffff33269510] bci=[2,23,3016] rc=1 vc=1483 vn=- li=-1 udi=- nc=0 flg=0x302
 [ERR] ...
knn-k commented 1 year ago

I tried to reproduce the assertion failure on x86 Linux (Link), but it did not fail.

knn-k commented 1 year ago

I reproduced the assertion failure on plinux (Link). The testcase is cmdLineTester_jvmtitests_hcr_openi9_none_SCC_3 in sanity.functional.

 [ERR] Assertion failed at /home/jenkins/workspace/Build_JDK11_ppc64le_linux_Personal/omr/compiler/optimizer/OMRSimplifierHandlers.cpp:5281: 0
 [ERR] VMState: 0x000507ff
 [ERR]  Node 0x7c277ad9b1d0 [ificmpne]: unexpected opcode provided to isReducible()
 [ERR] compiling java/net/URI$Parser.parseHierarchical(II)I at level: warm

 [ERR] Node context:
 [ERR] 
 [ERR] ...
 [ERR] n621n     ificmpne --> block_30 BBStart at n593n ()                                           [    0x7c277ad9b1d0] bci=[2,26,3016] rc=0 vc=1517 vn=- li=- udi=- nc=2 flg=0x20
 [ERR] n2309n      ior                                                                               [    0x7c277af7c170] bci=[2,23,3016] rc=1 vc=0 vn=- li=- udi=- nc=2
 [ERR] n1474n        icmpeq                                                                          [    0x7c277ae8bc70] bci=[2,23,3016] rc=1 vc=1517 vn=- li=- udi=- nc=2
 [ERR] n611n           ==>icall
 [ERR] n1473n          iconst 47 (X!=0 X>=0 )                                                        [    0x7c277ae8bc20] bci=[2,23,3016] rc=1 vc=1517 vn=- li=- udi=- nc=0 flg=0x104
 [ERR] n2304n        ior                                                                             [    0x7c277af7bfe0] bci=[2,23,3016] rc=1 vc=0 vn=- li=- udi=- nc=2
 [ERR] n1470n          icmpeq                                                                        [    0x7c277ae8bb30] bci=[2,23,3016] rc=1 vc=1517 vn=- li=- udi=- nc=2
 [ERR] n611n             ==>icall
 [ERR] n1469n            iconst 63 (X!=0 X>=0 )                                                      [    0x7c277ae8bae0] bci=[2,23,3016] rc=1 vc=1517 vn=- li=- udi=- nc=0 flg=0x104
 [ERR] n1466n          icmpeq                                                                        [    0x7c277ae8b9f0] bci=[2,23,3016] rc=1 vc=1517 vn=- li=- udi=- nc=2
 [ERR] n611n             ==>icall
 [ERR] n1465n            iconst 35 (X!=0 X>=0 )                                                      [    0x7c277ae8b9a0] bci=[2,23,3016] rc=1 vc=1517 vn=- li=- udi=- nc=0 flg=0x104
 [ERR] n2300n      iconst 0 (X==0 X>=0 X<=0 )                                                        [    0x7c277af7bea0] bci=[2,23,3016] rc=1 vc=1517 vn=- li=-1 udi=- nc=0 flg=0x302
 [ERR] ...
dylanjtuttle commented 1 year ago

This assertion lives in a function IfxcmpgeToIfxcmpeqReducer::isReducible which checks whether ifXcmpge nodes can be reduced to ifXcmpeq nodes, and is failing because it has received an ificmpne node, which is obviously incompatible with this function.

As shown from the stack backtrace from this previous comment, isReducible is being called from ificmpgeSimplifier, which is called through a macro declaration in omr/compiler/optimizer/OMRSimplifierTable.enum from OMR::Simplifier::simplify(TR::Node * node, TR::Block * block).

Since simplify appears to be a generic function which doesn't seem to make any assumptions about the opcode of the node passed into it, it certainly seems problematic for a generic function to be calling ificmpgeSimplifier on an ificmpne node.

I don't fully understand how simplifierOpts[node->getOpCodeValue()] turns into a call to ificmpgeSimplifier, but I do know that there are two macro declarations in omr/compiler/optimizer/OMRSimplifierTable.enum which expand to it:

#define ificmpgeSimplifierHandler ificmpgeSimplifier
#define ifiucmpgeSimplifierHandler ificmpgeSimplifier

There is also a macro declaration for a similar function ificmpneSimplifier:

#define ificmpneSimplifierHandler ificmpneSimplifier

One would presume we should be calling this function instead, but I need to figure out how these .enum files work in order to figure out what needs to be done to fix that.