libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libunwind-devel] [RFC][patch] Fix crash in _ULx86_64_tdep_trace whe


From: Paul Pluzhnikov
Subject: Re: [Libunwind-devel] [RFC][patch] Fix crash in _ULx86_64_tdep_trace when sigaltstack is too far away
Date: Tue, 22 Nov 2011 12:37:32 -0800

On Tue, Nov 22, 2011 at 12:12 PM, Lassi Tuura <address@hidden> wrote:

> The new patch looks good. I've tested on RHEL5-derived x86_64 system with
> GCC 4.6.1 build, and things look good in a couple of test applications I
> tried on.

Thanks!

> There's one new compilation warning in release mode, because 'uc' is only
> used in assert() in the new tdep_stash_frame(). Maybe protect the entire
> signal frame 'else if' body in tdep_stash_frame() #if UNW_DEBUG?
>
> ../../../libunwind/src/x86_64/Gstash_frame.c: In function 
> '_ULx86_64_stash_frame':
> ../../../libunwind/src/x86_64/Gstash_frame.c:84:22: warning: unused variable 
> 'uc' [-Wunused-variable]

The UNW_DEBUG could be true and assert() could still be empty.

How about this:

diff --git a/src/x86_64/Gstash_frame.c b/src/x86_64/Gstash_frame.c
index 92477e0..43695d6 100644
--- a/src/x86_64/Gstash_frame.c
+++ b/src/x86_64/Gstash_frame.c
@@ -81,11 +81,13 @@ tdep_stash_frame (struct dwarf_cursor *d, struct
dwarf_reg_state *rs)
        their ucontext_t offsets.  Confirm DWARF info agrees with the
        offsets we expect.  */

+#ifndef NDEBUG
     const unw_word_t uc = c->sigcontext_addr;

     assert (DWARF_GET_LOC(d->loc[RIP]) == uc + UC_MCONTEXT_GREGS_RIP);
     assert (DWARF_GET_LOC(d->loc[RBP]) == uc + UC_MCONTEXT_GREGS_RBP);
     assert (DWARF_GET_LOC(d->loc[RSP]) == uc + UC_MCONTEXT_GREGS_RSP);
+#endif

     Debug (4, " sigreturn frame\n");
   }

I've also changed the assert slightly (moving 'uc' to the right): I think
it's slightly easier to understand that way.

Full patch attached.


Thanks,
-- 
Paul Pluzhnikov

Attachment: libunwind-crash-in-fasttrace-20111122.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]