#690 closed defect (fixed)

Memory leak after deleting a task where C++ exception occurs

Reported by: pykhtin Owned by: Joel Sherrill
Priority: normal Milestone: 4.9
Component: score Version: 4.6
Severity: major Keywords:
Cc: bugs@…, strauman@… Blocked By:
Blocking:

Description

Memory leak occurs when deleting a task where C++ exception took place.
The malloc that doesn't have corresponding free is located in:
gcc-3.2.2\libstdc++-v3\libsupc++\eh_globals.cc, line 107

code around that place:
g = (cxa_eh_globals *) gthread_getspecific (globals_key);
if (! g)
{
if ((g = (cxa_eh_globals *)
std::malloc (sizeof (
cxa_eh_globals))) == 0 /* <=== that is !!! */

gthread_setspecific (globals_key, (void *) g) != 0)

std::terminate ();
g->caughtExceptions = 0;
g->uncaughtExceptions = 0;
}

Release:
4.6.0pre5

Environment:
Target: Rocky 512 board with Cyrix MediaGx? MMX-S CPU 300Mhz,
RAM 64M
Host: P4 HT 2800,512,WinXP,Cygwin
Tools:
gcc ver 3.2.3 (OAR Corp gcc-3.2.3-20030826/newlib-1.11.0-20030605-1)
ld ver 2.13.2.1
gdb ver 5.2
RTEMS config string:
../rtems-4.6.0pre5/configure --target=i386-rtems --prefix=/opt/rtems-4.6 --disable-multiprocessing --enable-rtems-debug --enable-cxx --enable-rdbg --disable-tests --enable-networking --enable-posix --disable-itron --disable-ada --disable-expada
BSP: pc586

How-To-Repeat:
The test attached:

  1. Creates a task
  2. throw/catch C++ exception in it
  3. deletes task

For monitoring leaks a few wrappers used (see comments and makefile)
To see the leak watch at malloc of 8 bytes after cxa_throw - it never gets freed.
Better run with gdb to see stack backtrace (see comments)

Attachments (4)

testexc.zip (3.2 KB) - added by pykhtin on 12/03/06 at 13:31:13.
testexc.zip
gxx_wrappers.c.diff#690 (6.7 KB) - added by pykhtin on 12/03/06 at 13:31:13.
gxx_wrappers.c.diff#690
testout.txt (863 bytes) - added by Joel Sherrill on 08/05/08 at 17:15:25.
Test output on CVS head
test_exceptions.tar.bz2 (3.4 KB) - added by Joel Sherrill on 08/05/08 at 17:18:03.
Updated version of test for 4.9 and other BSPs.

Download all attachments as: .zip

Change History (6)

comment:1 Changed on 05/20/05 at 18:45:17 by Joel Sherrill

Status: assignedwaiting

comment:2 Changed on 10/14/05 at 19:28:33 by strauman

Status: waitingassigned

Changed on 12/03/06 at 13:31:13 by pykhtin

Attachment: testexc.zip added

testexc.zip

Changed on 08/05/08 at 17:15:25 by Joel Sherrill

Attachment: testout.txt added

Test output on CVS head

Changed on 08/05/08 at 17:18:03 by Joel Sherrill

Attachment: test_exceptions.tar.bz2 added

Updated version of test for 4.9 and other BSPs.

comment:3 Changed on 08/05/08 at 17:18:30 by Joel Sherrill

Milestone: 4.9
rep_platform: All
Resolution: fixed
Status: assignedclosed

Closing. This appears to be fixed at some point along the way.

Note: See TracTickets for help on using tickets.