Bug 77153 - g++ 3.2 compiled program that uses templates & "iostream" leads to unlimited memory leaks in gdb
g++ 3.2 compiled program that uses templates & "iostream" leads to unlimited ...
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: gdb (Show other bugs)
8.0
i686 Linux
high Severity high
: ---
: ---
Assigned To: Elena Zannoni
Jay Turner
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-11-01 15:42 EST by Need Real Name
Modified: 2015-01-07 19:01 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-08-25 09:09:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
A transcript of gdb session & related. (1.57 KB, text/plain)
2002-11-13 06:33 EST, Need Real Name
no flags Details

  None (edit)
Description Need Real Name 2002-11-01 15:42:06 EST
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 16:46:44 EST
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 06:33:53 EST
Created attachment 84785 [details]
A transcript of gdb session & related.
Comment 3 Need Real Name 2002-11-13 06:36:30 EST
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 11:18:16 EST
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 09:09:42 EDT
I retested this with the latest gdb: 5.3.90-0.20030710.16. The problem is gone.

Note You need to log in before you can comment on or make changes to this bug.