This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/50678] [4.7 Regression] FAIL: c52104y on x86_64-apple-darwin10


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50678

--- Comment #39 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-10-17 20:37:01 UTC ---
> note that (despite the consistency within the code here) this differs from the
> order in gcc/config/i386/i386.h... (although these are not call-saved, still
> ... )

Yes, but this is OK as long as libc and libunwind agree.

> apropos the x86_64 variant:
> > This should be reported to Apple and probably fixed in the libc.  
> 
> is there a definitive "right" or "wrong'  - should I be patching
> gcc/config/i386/darwin.h to match the sigtramp and bug-file against
> libunwind? or just file a bug agains the sigtramp (the order there matches 
> the context order).

GCC isn't concerned here, this is a pure Darwin inconsistency, namely:

    loc_expr_for_reg (1, MCONTEXT_SS_RBX)

    loc_expr_for_reg (3, MCONTEXT_SS_RDX)

vs

    UNW_X86_64_RDX =  1,

    UNW_X86_64_RBX =  3,

The index number must be consistent: either 1 or 3 in both cases.

I think that the bug is in the unwind info of the libc, so the fix would be:

--- x86_64/sys/_sigtramp.s.0    2011-10-17 22:08:31.000000000 +0200
+++ x86_64/sys/_sigtramp.s      2011-10-17 22:08:42.000000000 +0200
@@ -195,9 +195,9 @@ LASFDE1:
           Only integer registers are described at present.    */

        loc_expr_for_reg (0, MCONTEXT_SS_RAX)
-       loc_expr_for_reg (1, MCONTEXT_SS_RBX)
+       loc_expr_for_reg (1, MCONTEXT_SS_RDX)
        loc_expr_for_reg (2, MCONTEXT_SS_RCX)
-       loc_expr_for_reg (3, MCONTEXT_SS_RDX)
+       loc_expr_for_reg (3, MCONTEXT_SS_RBX)
        loc_expr_for_reg (4, MCONTEXT_SS_RSI)
        loc_expr_for_reg (5, MCONTEXT_SS_RDI)
        loc_expr_for_reg (6, MCONTEXT_SS_RBP)

> It should be possible to produce a test-case w/out Ada (filing a bug that
> requires GCC+Ada is not likely to get far).   I wonder why my c++ case doesn't
> appear to fail.

Because %rbx is saved in the prologue of do_fail.

> poof-of-principle (needs some careful consideration of how to wrap it so we
> can control its removal when the bug is fixed).. [ using
> __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ is on my mind]
> 
> #if defined (__x86_64__)
>   /* Work around an unwinder bug in libSystem where the unwinder
>      and the context/sigtramp have different ideas about the reg.
>      numbers.  */
>   ucontext_t *uc = (ucontext_t *)ucontext ;
>   unsigned long t = uc->uc_mcontext->__ss.__rbx;
>   uc->uc_mcontext->__ss.__rbx = uc->uc_mcontext->__ss.__rdx;
>   uc->uc_mcontext->__ss.__rdx =t;
> #endif

This looks good to me.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]