[Converted from Gnats 2384] The appended exampled illustrates a problem in gdb's handling of baseclasses in shared libraries. When gdb resolves type information for class "derived" from objfile base-in-so.x, it fills in the TYPE_VPTR_BASETYPE field with class "base" from objfile base-in-so-base.so. When the program is rerun the type information for base-in-so-base.so is discarded leaving TYPE_VPTR_BASETYPE dangling. Release: 6.7.1 Environment: i386-linux How-To-Repeat: g++ -g -shared base-in-so-base.cc -o base-in-so-base.so g++ -g base-in-so.cc -o base-in-so.x -Wl,-rpath,`pwd` base-in-so-base.so gdb base-in-so.x break base-in-so.cc:20 run [hits breakpoint] print d.meth() $1 = 42 run Start at beginning? y [hits breakpoint] print d.meth() --> segv If the program doesn't hit a segv, it may just be that gdb got lucky. Putting in an assert will show the issue too: --- gdbtypes.c~ 2007-12-13 15:20:59.062220000 -0800 +++ gdbtypes.c 2007-12-13 15:21:39.408302000 -0800 @@ -1307,6 +1307,7 @@ fill_in_vptr_fieldno (struct type *type) fill_in_vptr_fieldno (baseclass); if (TYPE_VPTR_FIELDNO (baseclass) >= 0) { + gdb_assert (TYPE_OBJFILE (type) == TYPE_OBJFILE (baseclass)); TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (baseclass); TYPE_VPTR_BASETYPE (type) = TYPE_VPTR_BASETYPE (baseclass); break;
This was fixed a while back.