This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch] Update catch(...) handlers to deal with __forced_unwind
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Uros Bizjak <ubizjak at gmail dot com>
- Cc: Jonathan Wakely <jwakely at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "libstdc++" <libstdc++ at gcc dot gnu dot org>, Richard Henderson <rth at redhat dot com>
- Date: Mon, 4 Aug 2014 18:29:58 +0100
- Subject: Re: [patch] Update catch(...) handlers to deal with __forced_unwind
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4aoWvH_Gg9hLpfvBRwoZhiyqOT2sxE+grHoTdxT_+NGoA at mail dot gmail dot com> <20140606091959 dot GA30729 at redhat dot com> <CAFULd4a_aDtarKL3CrbV7Mq1e_yRbAYeu3bnJtzAWkFgjUkdLQ at mail dot gmail dot com> <20140606143107 dot GC30729 at redhat dot com> <CAFULd4ZR-Sg_5=NJh8v958bHVygmBB5YWqfvC9Q_ZeP9oTq2+A at mail dot gmail dot com>
On 16 July 2014 17:22, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Fri, Jun 6, 2014 at 4:31 PM, Jonathan Wakely <jwakely@redhat.com> wrote:
>> On 06/06/14 12:40 +0200, Uros Bizjak wrote:
>>>
>>> On Fri, Jun 6, 2014 at 11:19 AM, Jonathan Wakely <jwakely@redhat.com>
>>> wrote:
>>>>
>>>> On 06/06/14 10:27 +0200, Uros Bizjak wrote:
>>>>>
>>>>>
>>>>> These two tests timeout on alpha-linux-gnu:
>>>>>
>>>>> FAIL: 30_threads/async/forced_unwind.cc execution test
>>>>> WARNING: program timed out.
>>>>> FAIL: 30_threads/packaged_task/forced_unwind.cc execution test
>>>>> WARNING: program timed out.
>>>>
>>>>
>>>>
>>>> Sorry about that, I don't know why.
>>>>
>>>> Does pthread_exit(0) use a __forced_unwind exception on
>>>> alpha-linux-gnu? This should tell you ...
>>>>
>>>>
>>>> #include <bits/cxxabi_forced.h>
>>>> #include <pthread.h>
>>>>
>>>> void* f(void*) {
>>>> try
>>>> {
>>>> pthread_exit(0);
>>>> }
>>>> catch (__cxxabiv1::__forced_unwind const&)
>>>> {
>>>> __builtin_puts("unwind");
>>>> throw;
>>>> }
>>>> catch (...)
>>>> {
>>>> __builtin_puts("something else");
>>>> throw;
>>>> }
>>>> }
>>>>
>>>> int main()
>>>> {
>>>> pthread_t t;
>>>> pthread_create(&t, 0, f, 0);
>>>> pthread_join(t, 0);
>>>>
>>>> }
>>>
>>>
>>> Strange, I don't get anything ...
>>>
>>> $ g++ -lpthread pt.C
>>> $ ./a.out
>>
>>
>> That explains it then: the thread just goes away, and the waiting
>> function hangs forever expecting the future to be made ready.
>>
>> The test assumes pthread_exit is implemented by throwing
>> __forced_unwind, which apparently isn't true for all glibc targets.
>>
>> If the thread just goes away there's no way to make the future ready.
>> I guess we should just XFAIL it for alpha, and maybe other targets.
>
> Actually, the testcase uncovered a target bug in glibc NPTL, where
> saved stack pointer value in jmp_buf is not mangled as expected by
> unwind_stop function. The detailed analysis is available at [1].
>
> [1] https://sourceware.org/bugzilla/show_bug.cgi?id=17165
>
> Uros.
Uros, would backporting this to the 4.9 branch cause problems for alpha?
I assume since the change is already on trunk and the glibc bug is
already fixed that putting it on the 4.9 branch wouldn't make things
any worse than they are now?
The change is needed to make the code correct in the face of pthread
cancellations.