public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18649] New: terminate called after throwing - IOT/Abort trap (core dumped)
@ 2004-11-24 15:49 askees at appfluent dot com
  2004-11-24 18:42 ` [Bug c++/18649] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: askees at appfluent dot com @ 2004-11-24 15:49 UTC (permalink / raw)
  To: gcc-bugs

The threaded program used in this ticket crashes intermittently.  The error is 
sometimes "terminate called after throwing" and something "unwind called 
recursively".  A sample stack trace is shown below.

#0  0x00000000 in ?? ()
#1  0xd254ece4 in __gxx_exception_cleanup (code=539406920, exc=0x2026b228)
    at /home/downloads/gcc/gcc-3.4.2/libstdc++-v3/libsupc++/eh_throw.cc:52
#2  0xd26bdab0 in _Unwind_DeleteException (exc=0x2026b228)
    at /home/downloads/gcc/gcc-3.4.2/gcc/unwind.inc:277
#3  0xd2548530 in __cxa_end_catch ()
    at /home/downloads/gcc/gcc-3.4.2/libstdc++-v3/libsupc++/eh_catch.cc:119
#4  0x1000049c in thread_handler ()
#5  0xd004a410 in _pthread_body () from /usr/lib/libpthreads.a(shr_xpg5.o)
#6  0x00000000 in ?? ()
#7  0x00000000 in ?? ()
Previous frame identical to this frame (corrupt stack?)


To reproduce the bug, copy this program to "main.cpp" and compile it with "g++ -
pthread main.cpp".  Then, run the program with "while ./a.out do sleep 1; 
done".  After a minute or so, the program will die.  (It doesn't die every 
time, so that is why you need to run it in the loop.)

======================================================================
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/timeb.h>

#define NUM_THREADS 200
#define NUM_LOOPS 1000

pthread_mutexattr_t cs_attr;
pthread_mutex_t cs;
int cnt;

void*
thread_handler(void* idptr)
{
  printf("thread_handler (start)\n");

  for (int i=0; i<NUM_LOOPS; ++i)
  {
    try
    {
      throw "nothing";
    }
    catch(...)
    {
      //pthread_mutex_lock(&cs);

      time_t now = time(0);
      struct tm now_tm;
      localtime_r(&now, &now_tm);

      //pthread_mutex_unlock(&cs);
    }
  }

  pthread_mutex_lock(&cs);
  ++cnt;
  pthread_mutex_unlock(&cs);

  printf("thread_handler (stop)\n");
  return NULL;
}

int
main(int argc, char** argv)
{
  pthread_mutexattr_settype(&cs_attr, PTHREAD_MUTEX_RECURSIVE);
  pthread_mutex_init(&cs, &cs_attr);

  cnt = 0;

  for (int i=0; i<NUM_THREADS; ++i)
  {
    pthread_attr_t attr;

    int err = pthread_attr_init(&attr);
    if (err != 0)
    {
      printf("Could not initialize thread [errno=%d]\n", err);
      return 1;
    }

    err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    if (err != 0)
    {
      printf("Could not set detachable thread [errno=%d]\n", err);
      return 1;
    }

    pthread_t thread;
    err = pthread_create(&thread, &attr, thread_handler, (void*)NULL);
    if (err != 0) 
    {
      printf("Could not create thread [errno=%d]\n", err);
      return 1;
    }
  }

  bool stop = false;
  while(!stop)
  {
    sleep(1);

    pthread_mutex_lock(&cs);
    stop = (cnt == NUM_THREADS);
    printf("*** cnt = %d\n", cnt);
    pthread_mutex_unlock(&cs);
  }

  return 0;
}
======================================================================



gcc was configured as follows.

configure --enable-threads=posix --prefix=/usr/local/gcc/gcc-3.x.x --enable-lang
uages=c,c++ --disable-multilib

-- 
           Summary: terminate called after throwing - IOT/Abort trap (core
                    dumped)
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: askees at appfluent dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: powerpc-ibm-aix5.1.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18649


^ permalink raw reply	[flat|nested] 14+ messages in thread
[parent not found: <bug-18649-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2015-02-10 17:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-24 15:49 [Bug c++/18649] New: terminate called after throwing - IOT/Abort trap (core dumped) askees at appfluent dot com
2004-11-24 18:42 ` [Bug c++/18649] " pinskia at gcc dot gnu dot org
2004-11-24 21:29 ` askees at appfluent dot com
2004-12-06  5:03 ` [Bug target/18649] " pinskia at gcc dot gnu dot org
2005-04-08 20:18 ` cmchugh at callixa dot com
2005-04-13  0:41 ` cmchugh at callixa dot com
2005-07-22 23:42 ` pinskia at gcc dot gnu dot org
2005-08-11  9:18 ` jkj at sco dot com
     [not found] <bug-18649-4@http.gcc.gnu.org/bugzilla/>
2011-11-05  9:21 ` bucreev_1 at mail dot ru
2012-01-11 12:44 ` rguenth at gcc dot gnu.org
2012-01-11 15:27 ` bucreev_1 at mail dot ru
2013-09-11  9:31 ` ktietz at gcc dot gnu.org
2013-12-07 11:06 ` ktietz at gcc dot gnu.org
2015-02-10 17:20 ` ktietz at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).