Bug 11408 - gdb-7.1 spins and hangs in my normal work. (git bisection supplied)
Summary: gdb-7.1 spins and hangs in my normal work. (git bisection supplied)
Alias: None
Product: gdb
Classification: Unclassified
Component: breakpoints (show other bugs)
Version: 7.1
: P2 normal
Target Milestone: 7.1
Assignee: Sami Wagiaalla
: 11316 11890 (view as bug list)
Depends on:
Reported: 2010-03-20 19:00 UTC by Christopher Neufeld
Modified: 2011-06-01 20:31 UTC (History)
4 users (show)

See Also:
Last reconfirmed:

Potential patch (2.27 KB, patch)
2010-03-23 15:38 UTC, Sami Wagiaalla
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Neufeld 2010-03-20 19:00:24 UTC
I downloaded and compiled gdb-7.1, and found it to be unusable for me.  Whereas
gdb-7.0.1 worked well, 7.1 will often freeze when doing simple things like
setting a new breakpoint at a specified line number.  An strace of the gdb
process shows it to be spinning hard, calling the lseek() syscall over and over
(several thousand times is typical), before completing.  Setting a breakpoint
can take anywhere from 5 seconds to several minutes, with the CPU hard-spinning
the whole time.  This is entirely reproducible for me, I have just to set a
breakpoint at main(), run my debugging binary, then type "b 200" to add another
breakpoint at line 200 in the source module holding main.  This takes several
seconds in 7.1, and is effectively instantaneous in 7.0.1.  I have also seen it
hang when asked to print the value of a local variable.

I compiled gdb from sources, using gcc-4.2.4.

I realize that the git tree isn't fine-grained to individual commits, but having
the bisection ought still to help.  The bad behaviour first appears at revision
f03d5cd98559bdc7ee93b72383d9e50999310a97.  It was fixed at revision
f89f0ae081112db5dfad6264f481e6ca88b4d252, but unfortunately that revision is not
in the 7.1 release.

I've had to revert to 7.0.1 because of this bug.
Comment 1 Sami Wagiaalla 2010-03-22 15:41:43 UTC
Hi Christopher,

Thanks for the git bisect. I can back-port
f89f0ae081112db5dfad6264f481e6ca88b4d252 and related fixes to be put into 7.1.1

Can you give me a small reproducer so I can find out what the problem was
exactly and verify the fix ?

Comment 2 Christopher Neufeld 2010-03-23 14:05:34 UTC
I've been trying to find a non-proprietary binary that exhibits the behaviour. 
So far, it is quite reproducible on every binary I build for work, but that code
is not publicly available.

My KDE builds generate similar-sized binaries (50+ MB debugging binaries on
x86_64), and are built on the same compiler, but don't exhibit this behaviour. 
It's seems to be something subtle, I'm still trying to find some way for others
to reproduce the problem.
Comment 3 Sami Wagiaalla 2010-03-23 15:38:35 UTC
Created attachment 4674 [details]
Potential patch
Comment 4 Sami Wagiaalla 2010-03-23 15:40:45 UTC
could you try this branch:
$ git clone git://sourceware.org/git/archer.git
$ cd archer
$ git checkout archer-swagiaal-temp-71patch

this is 7.1 with the patch. I have also attached the patch if that is preferable.
Comment 5 Christopher Neufeld 2010-03-23 15:44:46 UTC
I applied the patch from the attachment, and the problem no longer appears in my
(reproducible) test cases.  I'm closing the bug.  Thank you.
Comment 6 Sami Wagiaalla 2010-03-23 15:48:40 UTC
Awesome!.. I'll post the fix upstream
Comment 7 cvs-commit@gcc.gnu.org 2010-04-08 17:15:27 UTC
Subject: Bug 11408

CVSROOT:	/cvs/src
Module name:	src
Branch: 	gdb_7_1-branch
Changes by:	swagiaal@sourceware.org	2010-04-08 17:15:12

Modified files:
	gdb            : ChangeLog buildsym.c cp-namespace.c 
	                 cp-support.h dwarf2read.c 
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.cp: gdb2384-base.cc gdb2384-base.h 

Log message:
	PR 11408: Backport using_directives memory leak fix.
	2010-04-08  Sami Wagiaalla  <swagiaal@redhat.com>
	PR Breakpoints/11408:
	* cp-namespace.c (cp_add_using): Deleted.
	(cp_add_using_directive): Use obstack allocations.
	Merged the function cp_add_using into this one.
	Added 'struct obstack *' argument.
	(cp_scan_for_anonymous_namespaces): Updated.
	* cp-support.h: Updated.
	* dwarf2read.c (read_import_statement): Updated.
	(read_namespace): Updated.
	* buildsym.c (finish_block): Reset using_directives pointer
	after block initialization.
	2010-03-22  Sami Wagiaalla  <swagiaal@redhat.com>
	* gdb.cp/gdb2384-base.h: Created 'namespace B'.
	* gdb.cp/gdb2384-base.cc: Use 'namespace B'.


Comment 8 Tom Tromey 2010-08-06 19:56:42 UTC
*** Bug 11890 has been marked as a duplicate of this bug. ***
Comment 9 Tom Tromey 2010-08-09 16:45:42 UTC
*** Bug 11316 has been marked as a duplicate of this bug. ***
Comment 10 David Greene 2011-06-01 20:31:41 UTC
This still happens for me with gdb 7.2.