harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elena Sayapina (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2144) [drlvm] [jit] [opt] ABCD causes unexpected NullPointerException instead of ArrayIndexOutOfBoundsException
Date Fri, 10 Nov 2006 12:02:37 GMT
[drlvm] [jit] [opt] ABCD causes unexpected NullPointerException instead of ArrayIndexOutOfBoundsException
---------------------------------------------------------------------------------------------------------

                 Key: HARMONY-2144
                 URL: http://issues.apache.org/jira/browse/HARMONY-2144
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
         Environment: Any
            Reporter: Elena Sayapina


ABCD causes unexpected NullPointerException instead of ArrayIndexOutOfBoundsException.

Consider that index of array element called inside a loop depends on the loop control variable.
An overflow occurs on some loop iteration and corrupts the value of loop control variable
so that it became negative.
An array tries to be accessed with an illegal negative index.
ArrayIndexOutOfBoundsException should be thrown in this case, but if abcd pass is turned on
it causes unexpected NullPointerException.

Please, see the code example below.

Code for reproducing:

public class abcdTest2 {

    private final int limit = 10000;

    public static void main(String[] args) {
        System.exit(new abcdTest2().test());
    }

    public int test() {
        System.out.println("Start abcdTest2 ...");
        int arr[] = new int[limit];
        int j=1;
        try {
            for(int k=2; k<limit; k=1+k+k*j) {
                if (k<0) System.out.println("---Overflow---");
                System.out.println("k=" + k + ": arr[" + (k-2) + "] will be called");
                arr[k] = arr[k-2];
                j = k*k;
             }
         } catch (ArrayIndexOutOfBoundsException e) {
             System.out.println("TEST PASSED ArrayIndexOutOfBoundsException was thrown");
             return 0;
         } catch (Exception e) {
             e.printStackTrace();
             System.out.println("TEST FAILED: unexpected exeption was thrown");
             return 1;
         }
         System.out.println("TEST FAILED: ArrayIndexOutOfBoundsException wasn't thrown");
         return 1;
    }
}

Steps to Reproduce:
Compile abcdTest2 class and run it on Harmony with '-Xem:server_static' option.

Output on Windows:

Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r473012, (Nov 10 2006), Windows/ia32/msvc 1310, release build
http://incubator.apache.org/harmony
Start abcdTest2 ...
k=2: arr[0] will be called
k=11: arr[9] will be called
k=1343: arr[1341] will be called
---Overflow---
k=-1872665345: arr[-1872665347] will be called
java.lang.NullPointerException
        at abcdTest2.test(abcdTest2.java)
        at abcdTest2.main(abcdTest2.java:6)
TEST FAILED: unexpected exception was thrown

Output on Linux:

x_ia32_0002_icc_r_H/bin/java -showversion -Xem:server_static abcdTest2                   
                                             
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0" 
pre-alpha : not complete or compatible
svn = r473012, (Nov 10 2006), Linux/ia32/icc 900, release build
http://incubator.apache.org/harmony
Start abcdTest2 ...
k=2: arr[0] will be called
k=11: arr[9] will be called
k=1343: arr[1341] will be called
---Overflow---
k=-1872665345: arr[-1872665347] will be called
java.lang.NullPointerException
        at abcdTest2.test(abcdTest2.java)
        at abcdTest2.main(abcdTest2.java:6)
TEST FAILED: unexpected exception was thrown

Output on RI:
Start abcdTest2 ...
k=2: arr[0] will be called
k=11: arr[9] will be called
k=1343: arr[1341] will be called
---Overflow---
k=-1872665345: arr[-1872665347] will be called
TEST PASSED ArrayIndexOutOfBoundsException was thrown




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message