Closed JeffersonYu1 closed 7 months ago
@hzongaro fyi
Looks like loop versioner issue.
Last failing index: 78 = loop versioner
$ java "-Xjit:limit={*C.main*}(optLevel=hot,traceFull,log=log.txt,lastOptIndex=78,count=0),disableAsyncCompilation" C
Exception in thread "main" java.lang.NullPointerException
at C.main(C.java)
$ java "-Xjit:limit={*C.main*}(optLevel=hot,traceFull,log=log.txt,disableLoopVersioner,count=0),disableAsyncCompilation" C
100000
@jdmpapin, I know you've been looking at some Loop Versioner issues recently. May I ask you to work with @BradleyWood on this problem?
The loop in m()
has two opposite-direction comparisons against j
in its condition. The j >= 0
condition ends up at the end of the loop body, just before the only back-edge, and so that's the one that loop versioner uses to predict the number of iterations when versioning bound checks. But since j
is increasing (j++
), versioner treated the 0 as an upper bound, as though the condition were j <= 0
, in which case the loop body would execute only once. In reality it executes twice, and on the second iteration it tries to access a[-1]
. The -1 is effectively zero-extended, and writing at a very large offset causes a segfault, which is then interpreted as an implicit null check failure
JDK 11/17/21 - Missing ArrayIndexOutOfBoundsException in a loop, and instead incorrectly throwing NullPointerException
System / OS / Java Runtime Information
Java version
Operating system details
Description
Incorrect result is given when running the following program. The bug affects 11.0.21, 17.0.9, 21.0.1 on default, hot, veryhot, and scorching levels.
Steps to reproduce
The following steps shows how to reproduce the bug on JDK 17.0.9 in a Ubuntu Linux environment.
Compile
Execute
Source code for an executable test case
Workaround
Disable JIT.