1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-14 20:28:12 +01:00
libunwind-eh_elf/src/x86_64
Arun Sharma 1010880548 Address x86_64 crashes when using sigaltstack
The crashes were tracked down to f->rpb_cfa_offset being incorrect.

The problem is that {rsp,rbp}_cfa_offset only have 15 bits, but for
SIGRETURN frame they are filled with:

// src/x86_64/Gstash_frame.c

   f->cfa_reg_offset = d->cfa - c->sigcontext_addr;
   f->rbp_cfa_offset = DWARF_GET_LOC(d->loc[RBP]) - d->cfa;
   f->rsp_cfa_offset = DWARF_GET_LOC(d->loc[RSP]) - d->cfa;

The problem is that the delta here can be arbitrarily large when
sigaltstack is used, and can easily overflow the 15 and 30-bit fields.

When signal handler starts running, the stack layout is:

 ... higher addresses ...
        ucontext
 CFA->
        __restore_rt (== pretcode in rt_sigframe from
                      linux-2.6/arch/x86/include/asm/sigframe.h)
 SP ->
       ... sighandler runs on this stack.

 ... lower addresses ...

This makes it very convenient to find ucontext from the CFA.

Attached patch re-tested on Linux/x86_64, no new failures.

Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
Reviwed-by: Lassi Tuura <lat@cern.ch>
2011-11-27 18:34:38 -08:00
..
Gcreate_addr_space.c Include sys/types.h when needed. 2010-03-06 16:43:39 +02:00
getcontext.S Implement a cheaper getcontext() 2011-04-05 22:07:05 -07:00
Gget_proc_info.c (unw_get_proc_info): Don't freak out if dwarf_make_proc_info() fails. 2005-05-03 09:13:17 +00:00
Gget_save_loc.c Fix incorrect calls to memset. 2011-10-02 22:43:28 -07:00
Gglobal.c Handle register nums > 16 on x86_64 2011-06-18 20:48:49 -07:00
Ginit.c Performance optimisations for fast trace. 2011-04-17 20:34:38 -07:00
Ginit_local.c Performance optimisations for fast trace. 2011-04-17 20:34:38 -07:00
Ginit_remote.c During the stack unwinding process, the return address points to 2010-04-24 19:16:09 -07:00
Gos-freebsd.c Performance optimisations for fast trace. 2011-04-17 20:34:38 -07:00
Gos-linux.c Address x86_64 crashes when using sigaltstack 2011-11-27 18:34:38 -08:00
Gregs.c Support walk over freebsd sigframes 2010-03-07 21:53:01 +02:00
Gresume.c Move local_resume to os-specific file. 2010-04-05 23:00:27 +03:00
Gstash_frame.c Address x86_64 crashes when using sigaltstack 2011-11-27 18:34:38 -08:00
Gstep.c Fast back-trace for x86_64 for only collecting the call stack. 2011-03-24 22:33:17 -07:00
Gtrace.c Address x86_64 crashes when using sigaltstack 2011-11-27 18:34:38 -08:00
init.h Performance optimisations for fast trace. 2011-04-17 20:34:38 -07:00
is_fpreg.c Include "libunwind_i.h" instead of "tdep.h". 2005-05-20 09:48:08 +00:00
Lcreate_addr_space.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Lget_proc_info.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Lget_save_loc.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Lglobal.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Linit.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Linit_local.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Linit_remote.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Lis_signal_frame.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
longjmp.S Fix _UI_siglongjmp_cont name 2010-03-08 15:55:29 +02:00
Los-freebsd.c Merge remote branch 'origin/master' into freebsd 2010-04-05 16:14:50 +03:00
Los-linux.c Refactor os specific code for x86 (both 32 and 64 bit). 2010-04-04 16:46:13 -07:00
Lregs.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Lresume.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Lstash_frame.c Fast back-trace for x86_64 for only collecting the call stack. 2011-03-24 22:33:17 -07:00
Lstep.c Remove unneeded includes of sys/types.h 2010-03-08 00:25:22 +02:00
Ltrace.c Fast back-trace for x86_64 for only collecting the call stack. 2011-03-24 22:33:17 -07:00
offsets.h Code for resume 2010-03-07 23:43:07 +02:00
regname.c Fix missing NELEMS -> ARRAY_SIZE adjustment. 2005-05-03 09:13:17 +00:00
setcontext.S Add my copyrights to several files that contain essential modifications 2010-04-10 01:42:26 +03:00
siglongjmp.S Fix _UI_siglongjmp_cont name 2010-03-08 15:55:29 +02:00
ucontext_i.h Arrange the FreeBSD ucontext offset definitions in ascending order. 2010-04-17 00:17:58 +03:00
unwind_i.h Performance optimisations for fast trace. 2011-04-17 20:34:38 -07:00