Bug 77153

Summary: g++ 3.2 compiled program that uses templates & "iostream" leads to unlimited memory leaks in gdb
Product: [Retired] Red Hat Linux Reporter: Need Real Name <olegm>
Component: gdbAssignee: Elena Zannoni <ezannoni>
Status: CLOSED RAWHIDE QA Contact: Jay Turner <jturner>
Severity: high Docs Contact:
Priority: high    
Version: 8.0CC: srevivo
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-08-25 13:09:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
A transcript of gdb session & related. none

Description Need Real Name 2002-11-01 20:42:06 UTC
Description of problem:
 When I compile a small C++ program with templates and <iostream>
 with g++ 3.2 and debug it with Kdbg, then when stepping through the 
 program at some moment Kdbg hangs, and with "top" i can see that gdb is  
 acquiring all the RAM it can get.

 Compiling exactly the same source with g++ 2.96 does not lead to
 any problems.

How reproducible: Always

Steps to Reproduce:
 1. Type: 
 cat > test.cpp
 #include <string>
 #include <iostream> 

 using namespace std;

 template<class X> void out (ostream& in, X& x)
 {
        // Here gdb starts allocating as much memory as it can get
        // eventually leading to system freeze
        cout << x;
 }

 int main()
 {
         cout << "This works fine!";
         out(cout, "aaa");
 }

2. Compile
 g++ -g test.cpp

3. [IMPORTANT] Be ready to kill gdb process or the system will 
freeze quite fast (thrashing).

4. Debug "a.out"
 kdbg a.out

5. Step through the program. 

Actual Results:  
 When stepping through function body:
  template<class X> void out (ostream& in, X& x)
  {
         cout << x;
  }
 gdb will start acuquiring immence amounts of memory. 
 [Be ready to kill the process!]

Additional info: 
* The same behaviour also occurs when replacing
    cout << x;
  with something similar like
    vector<X> v;
    v.push_back(x);
* My system is upgraded from Redhat 7.3, but the same resutls were
  also reproduced with clean Redhat 8 install.

Comment 1 Elena Zannoni 2002-11-12 21:46:44 UTC
Could you send me some more information? I need to know exactly the steps you
are doing in gdb,
and the initial banner that gets printed at gdb startup. You can just cut and
paste the session.
Is this stock gdb from 8.0? 

thanks


Comment 2 Need Real Name 2002-11-13 11:33:53 UTC
Created attachment 84785 [details]
A transcript of gdb session & related.

Comment 3 Need Real Name 2002-11-13 11:36:30 UTC
OK, I've attached a transcipt of the session now. GDB starts leaking on  
	info args  
See attachment - it is the output of "script" command.

Comment 4 Jeff Woods 2002-12-27 16:18:16 UTC
Just wanted to note that I was having an identical problem.  I upgraded my
gdb-5.2.1 package which came stock with RH8.0 to gdb-5.3post-0.20021129.3
(rawhide package) and my problem was solved.

Comment 5 Elena Zannoni 2003-08-25 13:09:42 UTC
I retested this with the latest gdb: 5.3.90-0.20030710.16. The problem is gone.