When using virtual inheritance, GCC emits in-charge (C1) and not-in-charge (C2) constructors, at the same source file:line One of these ctors could be garbage-collected by the linker, causing its line table to start at location 0. GDB does not ignore that line table, sets a breakpoint on 0, then gets: Cannot insert breakpoint 1. Error accessing memory address 0x0: Input/output error. The problem reproduces with GDB 7.2.50.20110311-cvs and GCC g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3 The problem does *not* reproduce with g++ (GCC) 4.6.0 20110219 (experimental), because in that version C1 ctor calls C2, preventing C2 from being GCd by the linker. Repro steps: /// --- foo.c struct Foo { Foo(int z) { x = z; } int x; }; struct Bar: virtual public Foo { Bar(int x) : Foo(x) { } }; int main(int argc, char *argv[]) { Foo f(42); return f.x + argc; } // Calls C2 ctor, but is GCd by linker void deadfn() { Bar b(12); } /// --- foo.c g++ -g foo.c -fno-inline -ffunction-sections -Wl,--gc-sections nm a.out | grep Foo 0000000000400622 W _ZN3FooC1Ei ### Note: only C1 constructor present! gdb ./a.out GNU gdb (GDB) 7.2.50.20110311-cvs Copyright (C) 2011 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 /tmp/a.out...done. (gdb) b Foo::Foo Breakpoint 1 at 0x0: file foo.c, line 3. (3 locations) (gdb) info b Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> 1.1 y 0x0000000000000000 foo.c:3 1.2 y 0x000000000000000b foo.c:3 1.3 y 0x000000000040062d in Foo::Foo(int) at foo.c:3 (gdb) r Warning: Cannot insert breakpoint 1. Error accessing memory address 0x0: Input/output error. Cannot insert breakpoint 1. Error accessing memory address 0xb: Input/output error. (gdb) q
Marking as dup. *** This bug has been marked as a duplicate of bug 12528 ***