[Linux-Xtensa] Forced unwinding in thread cancellation

Max Filippov jcmvbkbc at gmail.com
Sat Aug 15 15:04:30 UTC 2015


Chris, Baruch,

I see that the following issue haven't got any resolution:

On Thu, Oct 24, 2013 at 8:52 AM, Baruch Siach <baruch at tkos.co.il> wrote:
> The following patch fixes a number of tst-cancelx* tests:
>
> diff --git a/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h b/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
> index 4516d93..3f8a30a 100644
> --- a/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
> +++ b/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
> @@ -19,5 +19,5 @@
>    _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
>
>  #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
> -  ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
> +  ((uintptr_t) (_address) - (_adj) <= (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
>  #endif
>
> This macro is used in unwind_stop() to determine when to stop unwinding.
>
> However, all other architectures use '<' here as before this patch. Is there
> something special with the xtensa stack layout that requires this change?

With the current uClibc-ng a lot of nptl/tst-cancelx* fail. My investigation
shows two things:

- xtensa libgcc needs to use unwind-dw2-fde-dip.c instead of
  unwind-dw2-fde.c, otherwise forced unwinding doesn't find FDEs
  associated with the main executable code;

- '<=' instead of '<' just partially works around the real bug: I believe the
  problem is in the libgcc _Unwind_GetCFA: instead of context->cfa it
  should return context->sp. That gives consistent CFA across signal
  frames and CFA corresponds to the frame return address.

These two changes fix all currently failing NPTL cancellation/cleanup
tests. Interestingly, gcc testsuite results are not affected at all.

Does that sound right?

-- 
Thanks.
-- Max


More information about the linux-xtensa mailing list