This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
breakpoints/2245: gdb leaks memory when a breakpoint is hit but its condition is false
- From: abel at ispras dot ru
- To: gdb-gnats at sources dot redhat dot com
- Date: 30 Mar 2007 07:36:36 -0000
- Subject: breakpoints/2245: gdb leaks memory when a breakpoint is hit but its condition is false
- Reply-to: abel at ispras dot ru
>Number: 2245
>Category: breakpoints
>Synopsis: gdb leaks memory when a breakpoint is hit but its condition is false
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Fri Mar 30 08:38:01 BST 2007
>Closed-Date:
>Last-Modified:
>Originator: abel@ispras.ru
>Release: GNU gdb 6.6.50.20070329
>Organization:
>Environment:
ia64-unknown-linux-gnu, centos 4.4, Linux second 2.6.9-42.0.8.EL
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
>Description:
On ia64, gdb starts using a lot of memory when a conditional breakpoint is set on a hot place of code, and the breakpoint is hit many times before the condition becomes true. This was observed on cent os 4.4 with GNU gdb Red Hat Linux (6.3.0.0-1.132.EL4rh) and with the latest snapshot of gdb. This was also observed on RHEL 4 via the system gdb. We've also tried to compile one of the gdb snapshots using system gcc4 (4.1.0).
>How-To-Repeat:
1. Compile the following testcase:
[bonzo@second ~/temp]$ cat gdb-test.c
char gbuf[100];
void foo (int i)
{
char s[100] = "Hello world";
char buf[100], t[100];
while (i--)
{
sprintf (buf, " -- %d run\n", i);
strncpy (t, s, 100);
strncat (t, buf, 100);
}
strncpy (gbuf, t, 100);
}
int main(void)
{
foo (50000000);
return 0;
}
[bonzo@second ~/temp]$ gcc -O2 -g -o gdb-test gdb-test.c
2. Put a conditional breakpoint inside the loop:
b 10 if i == 1000000
r
3. Watch gdb in top eating your memory.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: