[Linux-Xtensa] Forced unwinding in thread cancellation

Baruch Siach baruch at tkos.co.il
Sun Aug 16 06:14:06 UTC 2015


Hi Max,

On Sat, Aug 15, 2015 at 06:04:30PM +0300, Max Filippov wrote:
> 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?

I don't remember the details, but I do remember that I never got to the bottom 
of this problem. Seeing this one fixed for real would be nice.

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -


More information about the linux-xtensa mailing list