dylan-lang / opendylan

Open Dylan compiler and IDE
http://opendylan.org/
Other
458 stars 69 forks source link

<division-by-zero-error> not signaled on OS X #633

Open cgay opened 10 years ago

cgay commented 10 years ago

This assertion from the common-dylan-test-suite

  check-condition("floor/(1, 0) signals <division-by-zero-error>",
                  <division-by-zero-error>,
                  begin
                    let x :: <integer> = 0;
                    for (i from 0 below 1)
                      x := x + 1;
                      x := floor/(x, 0);
                    end
                  end);

causes this out-of-language crash on OS X:

$ lldb _build/bin/common-dylan-test-suite-app
Current executable set to '/Users/cgay/dylan/src/opendylan/sources/_build/bin/common-dylan-test-suite-app' (i386).
(lldb) proc laun --  --test common-extensions-protocol-classes-test
proc laun --  --test common-extensions-protocol-classes-test
Process 24544 launched: '/Users/cgay/dylan/src/opendylan/sources/_build/bin/common-dylan-test-suite-app' (i386)
Process 24544 stopped
* thread #1: tid = 0x19319f, 0x97ed6590 libsystem_c.dylib`ldiv + 13, queue = 'com.apple.main-thread, stop reason = EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)
    frame #0: 0x97ed6590 libsystem_c.dylib`ldiv + 13
libsystem_c.dylib`ldiv + 13:
-> 0x97ed6590:  idivl  %esi
   0x97ed6592:  testl  %ecx, %ecx
   0x97ed6594:  js     0x97ed659d                ; ldiv + 26
   0x97ed6596:  testl  %edx, %edx

This doesn't seem to cause a crash on Linux. e.g., https://jenkins.opendylan.org/view/Open%20Dylan/job/opendylan-release-linux-precise-x86/lastCompletedBuild/testReport/

cgay commented 10 years ago

The generated C...

static D Kanonymous_of_test_protocol_definitionF206I () {
  DWORD i_T, i_;
  D T1;
  D xF2;
  D T3;
  D T4;
  D T5;
  DWORD T6;
  DWORD T7;
  D T8;
  DWORD T9;
  DWORD T10;
  DWORD T11_0;
  DWORD T11_1;
  DWORD quotient_;
  DWORD T13;
  DWORD T14;
  D T15;
  DWORD T16;

  // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:31
  // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:34
  xF2 = (D) 1;
  // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:35
  i_T = 1;
L0: ;
    // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:35
    i_ = i_T;
    // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:35
    T5 = primitive_machine_word_less_thanQ(i_,5);
    // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:35
    if (T5 != &KPfalseVKi) {
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:36
      T4 = xF2;
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:36
      T6 = primitive_cast_integer_as_raw(T4);
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:36
      T7 = primitive_machine_word_add_signal_overflow(T6,4);
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:36
      T8 = primitive_cast_raw_as_integer(T7);
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:36
      xF2 = T8;
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:37
      T3 = xF2;
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:37
      T9 = primitive_cast_integer_as_raw(T3);
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:37
      T10 = primitive_machine_word_shift_right(T9,2);
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:37
      T11_0 = primitive_machine_word_floorS_byref(T10,0,(DWORD*)&T11_1);
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:37
      quotient_ = T11_0;
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:37
      T13 = primitive_machine_word_shift_left_signal_overflow(quotient_,2);
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:37
      T14 = primitive_machine_word_logior(T13,1);
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:37
      T15 = primitive_cast_raw_as_integer(T14);
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:37
      xF2 = T15;
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:35
      T16 = primitive_machine_word_add_signal_overflow(i_,4);
      // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:35
      i_T = T16;
      goto L0;
    }
    // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:35
    // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:35
    T1 = &KPfalseVKi;
    MV_SET_ELT(0, &KPfalseVKi);
    MV_SET_COUNT(1);
    // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:35
  // /Users/cgay/dylan/src/opendylan/sources/common-dylan/tests/classes.dylan:31
  return(T1);
}
waywardmonkeys commented 10 years ago

This is because the C run-time doesn't install the signal handlers on any platform.

I have set Jenkins to ignore the test containing this on the builders using the C run-time which is why they no longer crash.