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

* [Bug c++/18649] terminate called after throwing - IOT/Abort trap (core dumped)
  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 ` pinskia at gcc dot gnu dot org
  2004-11-24 21:29 ` askees at appfluent dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-24 18:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-24 18:41 -------
This is already fixed in 3.4.3 and it is a dup of bug 13391.

*** This bug has been marked as a duplicate of 13391 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/18649] terminate called after throwing - IOT/Abort trap (core dumped)
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: askees at appfluent dot com @ 2004-11-24 21:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From askees at appfluent dot com  2004-11-24 21:29 -------
I downloaded 3.4.3 and the bug still exists.  So, it is not a duplicate of 
13391.  

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|DUPLICATE                   |
            Version|3.4.2                       |3.4.3


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
  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 ` pinskia at gcc dot gnu dot org
  2005-04-08 20:18 ` cmchugh at callixa dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-06  5:03 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |target


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
  2004-11-24 15:49 [Bug c++/18649] New: terminate called after throwing - IOT/Abort trap (core dumped) askees at appfluent dot com
                   ` (2 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: cmchugh at callixa dot com @ 2005-04-08 20:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cmchugh at callixa dot com  2005-04-08 20:18 -------
I downloaded and built 3.4.3 on AIX 5.2, and this bug does still exist; I tried
the following program (scarfed from 13391) and it crashes every time. Is there
any resolution/fix ? 


bluetrance:13391$ more a2.cpp
void mycall()
{
        throw 0;
}
bluetrance:13391$ more a1.cpp
                                                                                 
extern void mycall();
 
int main()
{
        try {
                mycall();
        } catch (int i) {
                return i;
        }
        return 1;
}
 
 
bluetrance:13391$ g++ -fPIC -DPIC -shared -o liba2.a a2.cpp
bluetrance:13391$ g++ -fPIC -DPIC -o a1 a1.cpp -L. -la2
bluetrance:13391$ a1
terminate called after throwing an instance of 'i'
IOT/Abort trap (core dumped)

bluetrance:build$ g++ --v
Reading specs from /usr/local/bin/../lib/gcc/powerpc-ibm-aix5.2.0.0/3.4.3/specs
Configured with: /export/xtegra3/gcc-3.4.3/gcc-3.4.3/configure
--enable-languages=c,c++ --enable-threads=aix --disable-nls
--prefix=/export/xtegra3/gcc-3.4.3/installdir
Thread model: aix
gcc version 3.4.3

-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
  2004-11-24 15:49 [Bug c++/18649] New: terminate called after throwing - IOT/Abort trap (core dumped) askees at appfluent dot com
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 14+ messages in thread
From: cmchugh at callixa dot com @ 2005-04-13  0:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cmchugh at callixa dot com  2005-04-13 00:41 -------

If I compile and link the example in my last comment (shown below) with
-pthread, it will always run. If I don't it will always core dump. This is with
g++ 3.4.3 on AIX 5.2. Does anyone know if the same program compiled with g++
3.3.3 will behave the same way on AIX 5.2 ? (i.e. run okay when compiled and
linked with -pthread but abort otherwise ?)

bluetrance:13391$ cat a2.cpp
void mycall()
{
        throw 0;
}
bluetrance:13391$ cat a1.cpp
                                                                                 
extern void mycall();
 
int main()
{
        try {
                mycall();
        } catch (int i) {
                return i;
        }
        return 1;
}
 
 
bluetrance:13391$ g++ -fPIC -DPIC -shared -pthread -o liba2.a a2.cpp
bluetrance:13391$ g++ -fPIC -DPIC -o a1 a1.cpp -pthread -L. -la2

-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
  2004-11-24 15:49 [Bug c++/18649] New: terminate called after throwing - IOT/Abort trap (core dumped) askees at appfluent dot com
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-22 23:42 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   GCC host triplet|powerpc-ibm-aix5.1.0.0      |
 GCC target 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

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
  2004-11-24 15:49 [Bug c++/18649] New: terminate called after throwing - IOT/Abort trap (core dumped) askees at appfluent dot com
                   ` (5 preceding siblings ...)
  2005-07-22 23:42 ` pinskia at gcc dot gnu dot org
@ 2005-08-11  9:18 ` jkj at sco dot com
  6 siblings, 0 replies; 14+ messages in thread
From: jkj at sco dot com @ 2005-08-11  9:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jkj at sco dot com  2005-08-11 09:18 -------
On UnixWare I have a very similar failure. It seems to be -fPIC that's wreaking
the havoc. I have an almost identical test case, and it aborts with:
terminate called after throwing an instance of 'int'
terminate called recursively

This only happens when compiling a2.cpp with -fPIC and producing a .so. If you
link the two together, it works fine. This was with 3.4.4.

-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
       [not found] <bug-18649-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2013-12-07 11:06 ` ktietz at gcc dot gnu.org
@ 2015-02-10 17:20 ` ktietz at gcc dot gnu.org
  5 siblings, 0 replies; 14+ messages in thread
From: ktietz at gcc dot gnu.org @ 2015-02-10 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #11 from Kai Tietz <ktietz at gcc dot gnu.org> ---
So waited long enough for a reply of PPC maintainer.  I assume it is fixed too.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
       [not found] <bug-18649-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 14+ messages in thread
From: ktietz at gcc dot gnu.org @ 2013-12-07 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Kai Tietz <ktietz at gcc dot gnu.org> ---
For mingw-code this bug is fixed.  It was caused by a bug in SjLj catch-reason.
 Issue is fixed for 32-bit and 64-bit mingw targets for all open branches.
As report was for different targets, it would be good if PPC maintainer could
verify that this issue is fixed for this target, too.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
       [not found] <bug-18649-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 14+ messages in thread
From: ktietz at gcc dot gnu.org @ 2013-09-11  9:31 UTC (permalink / raw)
  To: gcc-bugs

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

Kai Tietz <ktietz at gcc dot gnu.org> changed:

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

--- Comment #9 from Kai Tietz <ktietz at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #7)
> Still an issue?

gcc 4.8 and upward still have this issue.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
       [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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: bucreev_1 at mail dot ru @ 2012-01-11 15:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from bucreev_1 at mail dot ru 2012-01-11 15:26:45 UTC ---
There are no questions. Just to inform you that in version of gcc 4.5.2. this
example does not work.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
       [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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-11 12:44 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2012-01-11
                 CC|                            |dje at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-11 12:43:52 UTC ---
Still an issue?


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/18649] terminate called after throwing - IOT/Abort trap (core dumped)
       [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
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: bucreev_1 at mail dot ru @ 2011-11-05  9:21 UTC (permalink / raw)
  To: gcc-bugs

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

bucreev_1 at mail dot ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bucreev_1 at mail dot ru

--- Comment #6 from bucreev_1 at mail dot ru 2011-11-05 09:21:35 UTC ---
This example (Allen Skees 2004-11-24 15:48:41 UTC) also does not work correctly
when using gcc version 4.5.2.

D:\MinGW\bin>gcc -v
Using built-in specs.
COLLECT_GCC=D:\MinGW\bin\gcc.EXE
COLLECT_LTO_WRAPPER=d:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.2/configure
--enable-languages=c,c++,ada,fortran,obj
c,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared
--enable-libgo
mp --disable-win32-registry --enable-libstdcxx-debug
--enable-version-specific-r
untime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)


^ permalink raw reply	[flat|nested] 14+ messages in thread

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).