breakpoints/2245: gdb leaks memory when a breakpoint is hit but its condition is false

abel@ispras.ru abel@ispras.ru
Fri Mar 30 07:38:00 GMT 2007


>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:



More information about the Gdb-prs mailing list