[patch] Update catch(...) handlers to deal with __forced_unwind

Uros Bizjak ubizjak@gmail.com
Fri Jun 6 10:40:00 GMT 2014


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
$
$ g++ --version
g++ (Gentoo 4.8.2 p1.3r1, pie-0.5.8r1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Maybe Richard knows why...

>> [pid 18326] futex(0x2000027a1f4, FUTEX_WAKE_PRIVATE, 2147483647) = 0
>> [pid 18326] futex(0x12001a08c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
>> [pid 18326] madvise(0x20000454000, 8355840, MADV_DONTNEED) = 0
>> [pid 18326] exit(0)                     = ?
>> [pid 18326] +++ exited with 0 +++
>> <... futex resumed> )                   = 0
>> futex(0x12001a098, FUTEX_WAKE_PRIVATE, 2147483647) = 0
>> futex(0x12001a05c, FUTEX_WAIT_PRIVATE, 1, NULL
>>
>> ... the test hangs here ...
>
>
> Could I get a stack trace of the remaining thread at that point?

Reading symbols from ./forced_unwind.exe...done.
(gdb) r
Starting program: /space/homedirs/uros/test/forced_unwind.exe
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
[New Thread 0x20000c531f0 (LWP 22587)]
[Thread 0x20000c531f0 (LWP 22587) exited]
^C
Program received signal SIGINT, Interrupt.
0x0000020000289ca4 in pthread_cond_wait@@GLIBC_2.3.2 () from
/lib/libpthread.so.0
(gdb) bt
#0  0x0000020000289ca4 in pthread_cond_wait@@GLIBC_2.3.2 () from
/lib/libpthread.so.0
#1  0x00000200001279ec in
std::condition_variable::wait(std::unique_lock<std::mutex>&) ()
   from /usr/lib/gcc/alpha-unknown-linux-gnu/4.8.2/libstdc++.so.6
#2  0x0000000120001a80 in
wait<std::__future_base::_State_baseV2::wait()::<lambda()> > (__p=...,
__lock=..., this=0x12001a058)
    at /home/uros/gcc-build/alphaev68-unknown-linux-gnu/libstdc++-v3/include/condition_variable:98
#3  wait (this=0x12001a020) at
/home/uros/gcc-build/alphaev68-unknown-linux-gnu/libstdc++-v3/include/future:323
#4  _M_get_result (this=0x11fc8f190) at
/home/uros/gcc-build/alphaev68-unknown-linux-gnu/libstdc++-v3/include/future:618
#5  get (this=0x11fc8f190) at
/home/uros/gcc-build/alphaev68-unknown-linux-gnu/libstdc++-v3/include/future:783
#6  main () at /home/uros/gcc-svn/trunk/libstdc++-v3/testsuite/30_threads/async/forced_unwind.cc:38
(gdb)

Uros.



More information about the Gcc-patches mailing list