https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85471

bin cheng <amker at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amker at gcc dot gnu.org

--- Comment #6 from bin cheng <amker at gcc dot gnu.org> ---
I ran into a stackoverflow entry with following code:
#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <signal.h>

static void cleanup(void *ptr)
{
}

void *child(void *ptr)
{
  pthread_cleanup_push(cleanup, NULL);
  pthread_exit(NULL);
  pthread_cleanup_pop(1);
  return NULL;
}

int main()
{
  pthread_t foo;
  pthread_create(&foo, NULL, child, NULL);
  pthread_join(foo, NULL);
  return 0;
}

The abort can be reproduced when compiled using gcc-8.3 with following options:
$ g++ -o a.out test.cc -g -Wall -fexceptions  -pthread -static-libstdc++
-static-libgcc
$ gdb --args ./a.out
(gdb) r
(gdb) bt
#0  0x0000ffffbf4972c8 in raise () from /lib64/libc.so.6
#1  0x0000ffffbf498940 in abort () from /lib64/libc.so.6
#2  0x000000000040ec94 in _Unwind_SetGR ()
#3  0x0000000000401c4c in __gxx_personality_v0 ()
#4  0x0000ffffbec3fab8 in _Unwind_ForcedUnwind_Phase2
(exc=exc@entry=0xffffbf462670, context=context@entry=0xffffbf461560,
frames_p=frames_p@entry=0xffffbf461198)
    at ../../../libgcc/unwind.inc:182
#5  0x0000ffffbec3fea0 in _Unwind_ForcedUnwind (exc=0xffffbf462670,
stop=0xffffbf5f7950 <unwind_stop>, stop_argument=0xffffbf461a30) at
../../../libgcc/unwind.inc:217
#6  0x0000ffffbf5fa15c in _Unwind_ForcedUnwind () from /lib64/libpthread.so.0
#7  0x0000ffffbf5f7aac in __pthread_unwind () from /lib64/libpthread.so.0
#8  0x0000ffffbf5f1a08 in pthread_exit () from /lib64/libpthread.so.0
#9  0x0000000000401460 in child (ptr=0x0) at test.cc:13
#10 0x0000ffffbf5f0bb0 in start_thread () from /lib64/libpthread.so.0
#11 0x0000ffffbf53e4c0 in thread_start () from /lib64/libc.so.6

Issue with this case is because of static-libgcc, not sure if it's the same to
the original case.

Thanks

Reply via email to