#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 Dec 3, 2006 at 1:31:13 PM.
testexc.zip
gxx_wrappers.c.diff#690 (6.7 KB) - added by pykhtin on Dec 3, 2006 at 1:31:13 PM.
gxx_wrappers.c.diff#690
testout.txt (863 bytes) - added by Joel Sherrill on Aug 5, 2008 at 5:15:25 PM.
Test output on CVS head
test_exceptions.tar.bz2 (3.4 KB) - added by Joel Sherrill on Aug 5, 2008 at 5:18:03 PM.
Updated version of test for 4.9 and other BSPs.

Download all attachments as: .zip

Change History (6)

comment:1 Changed on May 20, 2005 at 6:45:17 PM by Joel Sherrill

Status: assignedwaiting

comment:2 Changed on Oct 14, 2005 at 7:28:33 PM by strauman

Status: waitingassigned

Changed on Dec 3, 2006 at 1:31:13 PM by pykhtin

Attachment: testexc.zip added

testexc.zip

Changed on Aug 5, 2008 at 5:15:25 PM by Joel Sherrill

Attachment: testout.txt added

Test output on CVS head

Changed on Aug 5, 2008 at 5:18:03 PM by Joel Sherrill

Attachment: test_exceptions.tar.bz2 added

Updated version of test for 4.9 and other BSPs.

comment:3 Changed on Aug 5, 2008 at 5:18:30 PM 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.