Harmony
  1. Harmony
  2. HARMONY-1775

[drlvm][jit][unit] Classlib test org.apache.harmony.luni.tests.util.Base64Test fails in OPT mode

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: DRLVM
    • Labels:
      None

      Description

      Passes in JET while fails in OPT in the following way:

      >java -showversion -Xem:opt TestBase64
      Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundatio
      n or its licensors, as applicable.
      java version "1.5.0"
      pre-alpha : not complete or compatible
      svn = r454267, (Oct 9 2006), Windows/ia32/msvc 1310, debug build
      http://incubator.apache.org/harmony
      JNI.ExceptionDescribe: java/lang/ArrayIndexOutOfBoundsException:

      java/lang/ArrayIndexOutOfBoundsException : (null)
      at org.apache.harmony.luni.util.Base64.decode (Base64.java: -1)
      at org.apache.harmony.luni.util.Base64.decode (Base64.java: -1)
      at TestBase64.main (TestBase64.java: 6)
      Error occured while running starter class: Exception left unhandled before destr
      oying VM
      JNI.ExceptionDescribe: java/lang/ArrayIndexOutOfBoundsException:

      java/lang/ArrayIndexOutOfBoundsException : (null)
      at org.apache.harmony.luni.util.Base64.decode (Base64.java: -1)
      at org.apache.harmony.luni.util.Base64.decode (Base64.java: -1)
      at TestBase64.main (TestBase64.java: 6)
      Error occured in starter class shutdown() method.

      A simple standalone test to reproduce the issue is attached.

      1. Base64.java
        6 kB
        Elena Semukhina
      2. Decode.java
        0.3 kB
        Egor Pasko
      3. RCE-mul-flags-undefined-fix.patch.txt
        0.4 kB
        Egor Pasko
      4. TestBase64.java
        0.3 kB
        Elena Semukhina

        Activity

        Hide
        Elena Semukhina added a comment -

        Test and imported class attached.

        Show
        Elena Semukhina added a comment - Test and imported class attached.
        Hide
        Egor Pasko added a comment -

        Elena, could cou reduce the test as much as possible, please?

        Show
        Egor Pasko added a comment - Elena, could cou reduce the test as much as possible, please?
        Hide
        Elena Semukhina added a comment -

        OK, I'll try.

        Show
        Elena Semukhina added a comment - OK, I'll try.
        Hide
        Elena Semukhina added a comment -
        Show
        Elena Semukhina added a comment - [drlvm] [unit] Blocked http://wiki.apache.org/harmony/Unit_Tests_Pass_on_DRLVM
        Hide
        Egor Pasko added a comment -

        I simplified the test (Decode.java)

        public class Decode {

        public static void main(String argv[])

        { Decode.decode(0); }

        public static void decode(int len) {
        if (len / 4 * 3 == 0)

        { System.out.println("PASS"); return; }

        System.out.println("FAIL");
        }
        }

        fails on OPT, funny, huh?

        Show
        Egor Pasko added a comment - I simplified the test (Decode.java) public class Decode { public static void main(String argv[]) { Decode.decode(0); } public static void decode(int len) { if (len / 4 * 3 == 0) { System.out.println("PASS"); return; } System.out.println("FAIL"); } } fails on OPT, funny, huh?
        Hide
        Egor Pasko added a comment -

        same reason as in HARMONY-1774. with RCE off all tests pass. May be closed as duplicate.

        Show
        Egor Pasko added a comment - same reason as in HARMONY-1774 . with RCE off all tests pass. May be closed as duplicate.
        Hide
        Geir Magnusson Jr added a comment -

        After applying HARMONY-1774, these tests still appear to fail ;

        geir@t42-laptop:~/dev/apache/harmony/enhanced/trunk/working_vm/build/deploy/jre/bin$ ./java -Xem:opt TestBase64

        java/lang/ArrayIndexOutOfBoundsException : (null)
        at org.apache.harmony.luni.util.Base64.decode (Base64.java: -1)
        at org.apache.harmony.luni.util.Base64.decode (Base64.java: -1)
        at TestBase64.main (TestBase64.java: 6)
        Uncaught exception in main:
        java.lang.ArrayIndexOutOfBoundsException
        at org.apache.harmony.luni.util.Base64.decode(Base64.java)
        at org.apache.harmony.luni.util.Base64.decode(Base64.java)
        at TestBase64.main(TestBase64.java:6)

        Show
        Geir Magnusson Jr added a comment - After applying HARMONY-1774 , these tests still appear to fail ; geir@t42-laptop:~/dev/apache/harmony/enhanced/trunk/working_vm/build/deploy/jre/bin$ ./java -Xem:opt TestBase64 java/lang/ArrayIndexOutOfBoundsException : (null) at org.apache.harmony.luni.util.Base64.decode (Base64.java: -1) at org.apache.harmony.luni.util.Base64.decode (Base64.java: -1) at TestBase64.main (TestBase64.java: 6) Uncaught exception in main: java.lang.ArrayIndexOutOfBoundsException at org.apache.harmony.luni.util.Base64.decode(Base64.java) at org.apache.harmony.luni.util.Base64.decode(Base64.java) at TestBase64.main(TestBase64.java:6)
        Hide
        Egor Pasko added a comment -

        in this code fragment RCE eliminates the CMP instruction after the IMUL instruction:
        I3: (ID:s4(EFLGS):uint32) =IMUL s6(EAX):int32,t13(EDX):int32
        I4: (ID:s4(EFLGS):uint32) =CMP s6(EAX):int32,t7(0):int32
        I5: JZ BB_2_epilog o21(8):int8 (IU:s4(EFLGS):uint32)

        ..but IMUL leaves ZF undefined (the IA-32 Manual says). Thus, CMP elimination is invalid.

        Nikolay, can you come across with the patch quickly?

        Show
        Egor Pasko added a comment - in this code fragment RCE eliminates the CMP instruction after the IMUL instruction: I3: (ID:s4(EFLGS):uint32) =IMUL s6(EAX):int32,t13(EDX):int32 I4: (ID:s4(EFLGS):uint32) =CMP s6(EAX):int32,t7(0):int32 I5: JZ BB_2_epilog o21(8):int8 (IU:s4(EFLGS):uint32) ..but IMUL leaves ZF undefined (the IA-32 Manual says). Thus, CMP elimination is invalid. Nikolay, can you come across with the patch quickly?
        Hide
        Nikolay Sidelnikov added a comment -

        IMUL and MUL should be excluded from group of instruction defines ZF properly

        Show
        Nikolay Sidelnikov added a comment - IMUL and MUL should be excluded from group of instruction defines ZF properly
        Hide
        Egor Pasko added a comment -

        Nikolay, thanks for your advice! Here is the patch. SUSE9, c-unit, kernel (except ThreadTest) pass

        Show
        Egor Pasko added a comment - Nikolay, thanks for your advice! Here is the patch. SUSE9, c-unit, kernel (except ThreadTest) pass
        Hide
        Geir Magnusson Jr added a comment -

        r464619

        Ubuntu 6 - test cases, smoke, c-unit, kernel

        Show
        Geir Magnusson Jr added a comment - r464619 Ubuntu 6 - test cases, smoke, c-unit, kernel

          People

          • Assignee:
            Geir Magnusson Jr
            Reporter:
            Elena Semukhina
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development