public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/13568] New: GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection
@ 2012-01-06 16:00 nickc at redhat dot com
  2012-01-06 17:22 ` [Bug breakpoints/13568] " nickc at redhat dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: nickc at redhat dot com @ 2012-01-06 16:00 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13568

             Bug #: 13568
           Summary: GDB can trigger a SIGBUS putting a breakpoint on a
                    source line removed by linker garbage collection
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
        AssignedTo: unassigned@sourceware.org
        ReportedBy: nickc@redhat.com
    Classification: Unclassified


If GDB is asked to place a breakpoint on a line of source code that has been
removed from the executable via linker garbage collection it can trigger a
SIGBUS fault.  Vis:

  % cat a.c
  int main()
  {
   return 0;
  }
  int fun ()
  {
   return 0;
  }

  % gcc -g3 -ffunction-sections -Wl.--gc-sections a.c

  % gdb -nw a.out
  (gdb) break a.c:6
  Bus error (core dumped)

This problem can be reproduced using the current (2012-01-06) GDB mainline
sources.  Note however that it needs a 4.6 or earlier version of GCC as the
compiler.  Newer GCCs create a .debug_loc section in the executable which
appears to avoid this problem.

The underlying issue is that the linker has not removed the redundant entries
from the .debug_line section, and hence this is a binutils bug.  On the other
hand it would be nice if GDB did not generate a SIGBUS when presented with
bogus debug information.

Detection of this problem originated from a thread in the binutils mailing list
that starts here:

http://sourceware.org/ml/binutils/2012-01/msg00047.html

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/13568] GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection
  2012-01-06 16:00 [Bug breakpoints/13568] New: GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection nickc at redhat dot com
@ 2012-01-06 17:22 ` nickc at redhat dot com
  2012-01-09 14:56 ` mjw at redhat dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: nickc at redhat dot com @ 2012-01-06 17:22 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13568

--- Comment #1 from Nick Clifton <nickc at redhat dot com> 2012-01-06 17:22:07 UTC ---
FYI I have created a Binutils PR for this issue as well:

http://sourceware.org/bugzilla/show_bug.cgi?id=13569

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/13568] GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection
  2012-01-06 16:00 [Bug breakpoints/13568] New: GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection nickc at redhat dot com
  2012-01-06 17:22 ` [Bug breakpoints/13568] " nickc at redhat dot com
@ 2012-01-09 14:56 ` mjw at redhat dot com
  2012-01-25 17:46 ` tromey at redhat dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mjw at redhat dot com @ 2012-01-09 14:56 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13568

Mark Wielaard <mjw at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mjw at redhat dot com

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/13568] GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection
  2012-01-06 16:00 [Bug breakpoints/13568] New: GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection nickc at redhat dot com
  2012-01-06 17:22 ` [Bug breakpoints/13568] " nickc at redhat dot com
  2012-01-09 14:56 ` mjw at redhat dot com
@ 2012-01-25 17:46 ` tromey at redhat dot com
  2012-01-26  9:57 ` nickc at redhat dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at redhat dot com @ 2012-01-25 17:46 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13568

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING
                 CC|                            |tromey at redhat dot com

--- Comment #2 from Tom Tromey <tromey at redhat dot com> 2012-01-25 17:44:35 UTC ---
I couldn't reproduce with gcc 4.5 and CVS head gdb; see appended transcript.

If it still fails for you, could you attach an executable?
That might help.


barimba. gcc --version
gcc (GCC) 4.5.1 20100430 (prerelease) [gcc-4_5-branch revision 158946]
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

barimba. gcc -g3 -ffunction-sections -Wl,--gc-sections a.c -o prbarimba. 
~/gnu/baseline-gdb/build/gdb/gdb -nw ./pr
GNU gdb (GDB) 7.4.50.20120125-cvs
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/tromey/gnu/PRS/gdb13568/pr...done.
(gdb) b a.c:6
No line 6 in file "a.c".
Make breakpoint pending on future shared library load? (y or [n]) n

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/13568] GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection
  2012-01-06 16:00 [Bug breakpoints/13568] New: GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection nickc at redhat dot com
                   ` (2 preceding siblings ...)
  2012-01-25 17:46 ` tromey at redhat dot com
@ 2012-01-26  9:57 ` nickc at redhat dot com
  2012-01-26 14:56 ` tromey at redhat dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: nickc at redhat dot com @ 2012-01-26  9:57 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13568

--- Comment #3 from Nick Clifton <nickc at redhat dot com> 2012-01-26 09:56:29 UTC ---
Created attachment 6177
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6177
Executable to demonstrate the problem

% gdb -nw a.bad
GNU gdb (GDB) 7.4.50.20120126-cvs
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /media/Devo/current/i686-pc-linux-gnu/tests/a.bad...done.
(gdb) break a.c:6
Bus error (core dumped)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/13568] GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection
  2012-01-06 16:00 [Bug breakpoints/13568] New: GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection nickc at redhat dot com
                   ` (3 preceding siblings ...)
  2012-01-26  9:57 ` nickc at redhat dot com
@ 2012-01-26 14:56 ` tromey at redhat dot com
  2012-01-26 15:29 ` tromey at redhat dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at redhat dot com @ 2012-01-26 14:56 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13568

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #4 from Tom Tromey <tromey at redhat dot com> 2012-01-26 14:56:10 UTC ---
Thanks.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/13568] GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection
  2012-01-06 16:00 [Bug breakpoints/13568] New: GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection nickc at redhat dot com
                   ` (4 preceding siblings ...)
  2012-01-26 14:56 ` tromey at redhat dot com
@ 2012-01-26 15:29 ` tromey at redhat dot com
  2012-01-30 20:11 ` cvs-commit at gcc dot gnu.org
  2012-01-30 20:13 ` tromey at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at redhat dot com @ 2012-01-26 15:29 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13568

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at sourceware    |tromey at redhat dot com
                   |dot org                     |

--- Comment #5 from Tom Tromey <tromey at redhat dot com> 2012-01-26 15:27:59 UTC ---
The bug is that there is a recursive include in the .debug_macro section.
This causes gdb to overrun the stack.

I'm testing a fix.

Contents of the .debug_macro section:

  Offset:                      0x0
  Version:                     4
  Offset size:                 4
  Offset into .debug_line:     0x0

 DW_MACRO_GNU_transparent_include - offset : 0x0
 DW_MACRO_GNU_start_file - lineno: 0 filenum: 1 filename: a.c
 DW_MACRO_GNU_end_file

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/13568] GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection
  2012-01-06 16:00 [Bug breakpoints/13568] New: GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection nickc at redhat dot com
                   ` (5 preceding siblings ...)
  2012-01-26 15:29 ` tromey at redhat dot com
@ 2012-01-30 20:11 ` cvs-commit at gcc dot gnu.org
  2012-01-30 20:13 ` tromey at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2012-01-30 20:11 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13568

--- Comment #6 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> 2012-01-30 20:10:40 UTC ---
CVSROOT:    /cvs/src
Module name:    src
Changes by:    tromey@sourceware.org    2012-01-30 20:10:33

Modified files:
    gdb            : ChangeLog dwarf2read.c 

Log message:
    PR breakpoints/13568:
    * dwarf2read.c (dwarf_decode_macro_bytes): Add 'include_hash'
    argument.  Check for recursive includes.
    (dwarf_decode_macros): Create an include hash.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13789&r2=1.13790
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.610&r2=1.611

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug breakpoints/13568] GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection
  2012-01-06 16:00 [Bug breakpoints/13568] New: GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection nickc at redhat dot com
                   ` (6 preceding siblings ...)
  2012-01-30 20:11 ` cvs-commit at gcc dot gnu.org
@ 2012-01-30 20:13 ` tromey at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at redhat dot com @ 2012-01-30 20:13 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13568

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |7.5

--- Comment #7 from Tom Tromey <tromey at redhat dot com> 2012-01-30 20:12:33 UTC ---
Fixed.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-01-30 20:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-06 16:00 [Bug breakpoints/13568] New: GDB can trigger a SIGBUS putting a breakpoint on a source line removed by linker garbage collection nickc at redhat dot com
2012-01-06 17:22 ` [Bug breakpoints/13568] " nickc at redhat dot com
2012-01-09 14:56 ` mjw at redhat dot com
2012-01-25 17:46 ` tromey at redhat dot com
2012-01-26  9:57 ` nickc at redhat dot com
2012-01-26 14:56 ` tromey at redhat dot com
2012-01-26 15:29 ` tromey at redhat dot com
2012-01-30 20:11 ` cvs-commit at gcc dot gnu.org
2012-01-30 20:13 ` tromey at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).