Re: Segfault in _Unwind_* code called from pthread_exit

From: Mark Millard <markmi_at_dsl-only.net>
Date: Fri, 25 Aug 2017 13:56:06 -0700
Tijl Coosemans tijl at FreeBSD.org wrote on
Fri Aug 25 15:40:10 UTC 2017 :

> So both GCC and LLVM unwinding look up the return address in the CFI
> table and fail when the return address is garbage, but LLVM treats this
> as an end-of-stack condition while GCC further tries to see if the
> return address points to a signal trampoline by testing the instruction
> bytes at that address.  On amd64 the garbage address is unreadable so it
> segfaults.  On i386 it is readable, the test fails and GCC returns
> end-of-stack.
> 
> To fix the crash and get predictable behaviour in the other cases I
> propose always setting the return address to 0.  The attached patch does
> this for i386 and amd64.  I don't know if other architectures need a
> similar patch.

If this is fixed it is possibly the fix for bugzilla report:

Bug 221423 - gcc std::locale(LocaleName) crashes instead of
throwing an exception


It may also fix some examples mentioned in comments for:

Bug 221288 - lang/gcc5 links against libsupc++ when compiling

but the original description did not happen to involve
exception handling from what I can see. Instead __dynamic_cast
failed.

===
Mark Millard
markmi at dsl-only.net
Received on Fri Aug 25 2017 - 18:56:10 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:13 UTC