JDK-8139771 : Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8u112,9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-10-16
  • Updated: 2022-05-19
  • Resolved: 2016-01-11
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 9
9 b105Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Code in PhiNode::unique_input() causes CastPPs to be eliminated and can result in dependency of a load on a null check to be lost. Here is an example test case:

public class TestEliminatedCastPP {

    static TestEliminatedCastPP saved;
    static TestEliminatedCastPP saved_not_null;

    int f;

    static int test(TestEliminatedCastPP obj, int[] array, boolean flag) {
        int ret = array[0] + array[20];
        saved = obj;
        if (obj == null) {
            return ret;
        }
        saved_not_null = obj;

        int i = 0;
        for (; i < 10; i++);

        ret += array[i];

        TestEliminatedCastPP res;
        if (flag) {
            res = saved;
        } else {
            res = saved_not_null;
        }
        return ret + res.f;
    }

    static public void main(String[] args) {
        int[] array = new int[100];
        TestEliminatedCastPP obj = new TestEliminatedCastPP();
        for (int i = 0; i < 20000; i++) {
            test(obj, array, (i%2) == 0);
        }
        test(null, array, true);
    }
}

Crashes on sparc with:
-XX:+StressGCM 

ILW=H(crash)L(never seen in the wild, requires stress option)H(none)=P2
Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/9e17d9e4b59f User: lana Date: 2016-02-10 21:55:30 +0000
10-02-2016

URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/9e17d9e4b59f User: roland Date: 2016-01-11 21:56:50 +0000
11-01-2016