[Bug 690] Memory leak after deleting a task where C++ exception occurs

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Tue Aug 5 18:15:26 UTC 2008


http://www.rtems.org/bugzilla/show_bug.cgi?id=690


Joel Sherrill <joel.sherrill at oarcorp.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |WAITING

strauman at slac.stanford.edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |ASSIGNED


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)

--- Comment #1 from pykhtin at prosoft.ural.ru  2004-10-15 00:12:48 ---
Fix:
Till S: attachment 1 provides a fix (provide a DTOR to task variable). The fix also reduces a preemption-disabled section
of code.
NOTE: I recommend overhauling the gthread implementation avoiding the use of task variables.

--- Comment #2 from Joel Sherrill <joel.sherrill at oarcorp.com>  2005-05-20 14:45:17 ---
State-Changed-From-To: open->feedback
State-Changed-Why: Is this still an issue?  If so provide an updated patch for
the current 4.6 branch and CVS head.  Otherwise, we need to
close it.


--- Comment #3 from strauman at slac.stanford.edu  2005-10-14 15:28:33 ---
State-Changed-From-To: feedback->open
State-Changed-Why: Looked at it (gcc-3.2.3 / rtems-4.6.5) and IMO it is still
an issue and I still believe my patch fixes this.


--- Comment #4 from Joel Sherrill <joel.sherrill at oarcorp.com>  2008-08-05 13:15:25 ---
Created an attachment (id=557)
 --> (http://www.rtems.org/bugzilla/attachment.cgi?id=557)
Test output on CVS head


-- 
Configure bugmail: http://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the bugs mailing list