This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/6678: Memory leak when throwing exceptions (c++)



>Number:         6678
>Category:       c++
>Synopsis:       g++ 3.1 leaks memory when throwing exceptions
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu May 16 08:06:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Kristijan Caprdja
>Release:        3.1
>Organization:
H.A.N.D. GmbH
>Environment:
System: SunOS jake 5.7 Generic_106542-12 i86pc i386 i86pc
Architecture: i86pc

	
host: i386-pc-solaris2.7
build: i386-pc-solaris2.7
target: i386-pc-solaris2.7
configured with: ../gcc-3.1/configure --prefix=/home/caprdja/gcc/install/solaris --disable-shared --enable-threads
>Description:
	When making a nested call to a function and a function throws an exceptions,
	a memory leak will occur.
	This bug report is generated on a Solaris machine, but the same bug 
	appears on Linux (Debian/Potato kernel 2.2).
>How-To-Repeat:

	One way to reproduce this bug:	
	------ snip ----
	int fkt1()
	{
	    throw 1;
	}

	void fkt(int)
	{
	}

	int 
	main(int argc, char * argv[])
	{
	    for(;;) {
		try {
		    fkt(fkt1());
		}
		catch(...){
		}
	    }
	    return 0;
	}

	------ snap -----
	This program will eventually crash because all memory 
	will be exausted.

	Another way to reproduce the bug:

	----- snip -------

	#include <iostream>

	int fkt1()
	{
	    throw 1;
	}

	int 
	main(int argc, char * argv[])
	{
	    for(;;) {
		try {
		    std::cout << fkt1();
		}
		catch(...){
		}
	    }
	    return 0;
	}
	----- snap --------
	Same story, program will eventually crash.

>Fix:
	not known
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]