Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1264851

Division of int x80000000 by -1 X86 Solaris

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.0.2
    • hotspot
    • x86
    • solaris_9

      The specification says

      There is one special case that does not satisfy this rule: if the dividend
      is the negative integer of largest possible magnitude for its type, and the
      divisor is -1, then integer overflow occurs and the result is equal to the
      dividend. Despite the overflow, no exception is thrown in this case.

      It works this way for solaris sparc but not solaris intel.

      The JCK java_spec expr184 tests this statement. The code below demonstrates the bug.

      // class to test div by -1 on x86
      final class DivTest
      {
              int i = 0x80000000;

              public DivTest()
              {
                      System.out.println("i / -1");
                      System.out.println(i / -1);
              }
              public static void main(String[] args)
              {
                      new DivTest();
              }
      }

      i / -1
      SIGFPE 8* arithmetic exception
          si_signo [8]: SIGFPE 8* arithmetic exception
          si_errno [0]: Error 0
          si_code [1]: FPE_INTOVF [addr: 0x8060cc9]

              stackbase=80479E0, stackpointer=804782C

      Full thread dump:
          "Finalizer thread" (TID:0xdef003b0, sys_thread_t:0xdeb16d88) prio=1
          "Async Garbage Collector" (TID:0xdef00368, sys_thread_t:0xdeb38d88) prio=1
          "Idle thread" (TID:0xdef00320, sys_thread_t:0xdeb5ad88) prio=0
          "clock handler" (TID:0xdef001f8, sys_thread_t:0xdeb7cd88) prio=11
          "main" (TID:0xdef000a0, sys_thread_t:0x8098220) prio=5 *current thread*
              DivTest.<init>(DivTest.java:8)
              DivTest.main(DivTest.java:13)
      Monitor Cache Dump:
      Registered Monitor Dump:
          Finalize me queue lock: unowned
          Thread queue lock: unowned
          Class lock: unowned
          Java stack lock: unowned
          Code rewrite lock: unowned
          Heap lock: unowned
          Has finalization queue lock: unowned
          Monitor IO lock: unowned
          Child death monitor: unowned
          Event monitor: unowned
          I/O monitor: unowned
          Alarm monitor: unowned
              Waiting to be notified:
                  "clock handler"
          Sbrk lock: unowned
          Monitor cache lock: unowned
          Monitor registry: monitor owner: "main"
      Thread Alarm Q:
      Abort(coredump)

            duke J. Duke
            bcaperonsunw Bren Caperon (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: