Bug 7612 - Memory leaks in cplus-dem.c
Summary: Memory leaks in cplus-dem.c
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 3.4.0
Assignee: Daniel Jacobowitz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-16 06:06 UTC by Daniel Jacobowitz
Modified: 2004-07-30 19:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Jacobowitz 2002-08-16 06:06:00 UTC
(Should there be a libiberty category in GNATS?)

I'm tracking down some bugs in which GDB consumes excessive memory.  One of
them is definitely foolishness in how ofter we call the demangler, but in
fixing that I've discovered that the demangler itself leaks memory.  Calling
cplus_demangle with DMGL_ARM | DMGL_ANSI and this string, for example:

_M_get_node__t19_Rb_tree_alloc_base3Zt4pair2ZCt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0Zt3map4Zt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0ZsZt4less1Zt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0Zt9allocator1ZsZt9allocator1Zt3map4Zt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0ZsZt4less1Zt12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b1i0Zt9allocator1Zsb1

leaks about 4K every time, above and beyond the malloc'd return value.
Anyone have an idea why?

Release:
HEAD
Comment 1 Daniel Jacobowitz 2003-02-13 17:21:20 UTC
From: drow@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/7612
Date: 13 Feb 2003 17:21:20 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	drow@gcc.gnu.org	2003-02-13 17:21:20
 
 Modified files:
 	libiberty      : ChangeLog cplus-dem.c 
 
 Log message:
 	Fix PR c++/7612.
 	* cplus-dem.c (demangle_signature): Call string_delete.
 	Remove extra string_init.
 	(demangle_arm_hp_template): Call string_delete instead of
 	string_clear.  Add missing string_delete call.
 	(demangle_qualified): Add missing string_delete call.
 	(do_type): Remove unused variable btype.  Add missing string_delete
 	call.  Call string_delete instead of string_clear.
 	(demangle_fund_type): Move variable btype inside of the switch
 	statement.  Add missing string_delete call.
 	(do_arg): Call string_delete instead of string_clear.  Remove extra
 	string_init.
 	(demangle_nested_args): Free work->previous_argument.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libiberty/ChangeLog.diff?cvsroot=gcc&r1=1.409&r2=1.410
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libiberty/cplus-dem.c.diff?cvsroot=gcc&r1=1.89&r2=1.90
 
Comment 2 Wolfgang Bangerth 2003-03-25 01:21:28 UTC
State-Changed-From-To: open->feedback
State-Changed-Why: A patch for this PR has been checked in in February. Is this
    fixed now?
    
    W.
Comment 3 Daniel Jacobowitz 2003-03-25 02:33:37 UTC
Responsible-Changed-From-To: unassigned->drow
Responsible-Changed-Why: Mine.
Comment 4 Daniel Jacobowitz 2003-03-25 02:33:37 UTC
State-Changed-From-To: feedback->closed
State-Changed-Why: Patch checked in, thanks for the prod.