From c8d441345fb301e6f5aa828f217d377dbc4f252b Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Mon, 22 Feb 2016 07:08:10 +0300 Subject: xtensa: fix stack unwinding over __default_sa_restorer For some xtensa cores generated code gets arranged so that __default_sa_restorer immediately follows preceding function. E.g.: 40a1b: c03340 sub a3, a3, a4 40a1e: f01d retw.n 00040a20 <__default_sa_restorer>: 40a20: e1a022 movi a2, 225 40a23: 005000 syscall ... Contents of the .eh_frame section: ... 000007f4 00000014 000007f8 FDE cie=00000000 pc=0004076c..00040a20 DW_CFA_advance_loc4: 3 to 0004076f DW_CFA_def_cfa_offset: 48 Due to the way xtensa libgcc uw_frame_state_for calls _Unwind_Find_FDE for non-signal frames, FDE for the previous function is found during thread cancellation signal stack unwinding in that case. Signal stack frame is not recognized and is not unwound properly, breaking cleanup routines calling for cancelled thread. Insert padding before the __default_sa_restorer so that no FDE is found for it, MD_FALLBACK_FRAME_STATE_FOR is called by uw_frame_state_for and the frame is correctly recognized as signal frame. Signed-off-by: Max Filippov --- libc/sysdeps/linux/xtensa/sigrestorer.S | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libc/sysdeps') diff --git a/libc/sysdeps/linux/xtensa/sigrestorer.S b/libc/sysdeps/linux/xtensa/sigrestorer.S index 474a89319..697f54e1d 100644 --- a/libc/sysdeps/linux/xtensa/sigrestorer.S +++ b/libc/sysdeps/linux/xtensa/sigrestorer.S @@ -11,6 +11,12 @@ #endif .text + /* This space separates __default_sa_restorer from the previous + * function, so that its corresponding FDE is not mistakenly found + * by the libgcc stack unwinder. This is important for correct signal + * stack unwinding. + */ + .space 1 .align 4 .global __default_sa_restorer .type __default_sa_restorer, @function -- cgit v1.2.3