iains / gcc-darwin-arm64

GCC master branch for Darwin with experimental support for Arm64. Currently GCC-15.0.0 [October 2024]
GNU General Public License v2.0
269 stars 34 forks source link

Test failures: gcc.dg/cleanup-{8,9,10,11}.c #66

Closed fxcoudert closed 1 year ago

fxcoudert commented 2 years ago
FAIL: gcc.dg/cleanup-8.c execution test
FAIL: gcc.dg/cleanup-9.c execution test
FAIL: gcc.dg/cleanup-10.c execution test
FAIL: gcc.dg/cleanup-11.c execution test

All four failures are identical, the simplest code is cleanup-8.c.

The abort that is triggered is this one:

static _Unwind_Reason_Code
force_unwind_stop (int version, _Unwind_Action actions,
                   _Unwind_Exception_Class exc_class,
                   struct _Unwind_Exception *exc_obj,
                   struct _Unwind_Context *context,
                   void *stop_parameter)
{
  if (actions & _UA_END_OF_STACK)
    abort ();
  return _URC_NO_REASON;
}

That function, force_unwind_stop(), is called 7 times:

Running the same code under Linux, the seventh time the argument is still _UA_CLEANUP_PHASE | _UA_FORCE_UNWIND.

PS: sorry @iains I couldn't reduce that one much further, I really don't know much about exceptions and this unwinding code.

iains commented 2 years ago

thanks. This looks exciting to debug ..

iains commented 2 years ago

Out of interest, does the same code build and/or function if the compiler is clang?

(since the unwinder we are using is libunwind [not libgcc_s] I wonder if the actions are supported).

iains commented 2 years ago

to answer my own question: clang ~/src-local/gcc-master/gcc/testsuite/gcc.dg/cleanup-8.c -I gcc/include -fexceptions -fnon-call-exceptions -o t ./t (no output)

$ ./gcc/xgcc -Bgcc ~/src-local/gcc-master/gcc/testsuite/gcc.dg/cleanup-8.c -fexceptions -fnon-call-exceptions -o t $ ./t Abort trap: 6

(I suppose at least we can compare the unwind frames between the two)

iains commented 1 year ago

these fails are triggered by a missing FDE record that updates the CFA to refer to the saved FP(we actually save the FP, but did not update the CFA to refer to it).

For the record, in principle, the unwinder should be able to use the existing CFA (stack pointer) info - but even if that is (a) a bug and (b) it gets fixed for some future OS release, that will not help the existing ones.

The fix was to force the FP on for Darwin (which is OK, since the ABI mandates a FP for non-leaf functions).

We will allow the user to override this with -fomit-frame-pointer on the assumption that such a user knows the intent.