This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Segfault if printing constructor..
- From: David Lecomber <david at lecomber dot net>
- To: gdb <gdb at sources dot redhat dot com>
- Date: Wed, 04 Jan 2006 14:00:02 +0000
- Subject: Segfault if printing constructor..
With the simple program here, gdb 6.3 or gdb 6.4, and current CVS, g++
4.0.2 (fedora 4 x86), we can get a segfault every time with a simple
three liner:
break 'X::f'
run
print X
class X
{
public:
X(); // standard constructor
void f();
};
int main(int argc, char **argv)
{
X x;
x.f();
return 1;
}
X::X()
{
}
void X::f()
{
}
gcc 3.2.2 code does not produce the problem, but perhaps a bit of
resilience could be added to GDB to cope nicely. Essentially, inside
value_fn_field, the lookup_symbol call finds the class, not the
constructor, and we get a segfault as sym->ginfo->value->block is null
here:
struct value*
value_fn_field (struct value **arg1p, struct fn_field *f, int j, struct
type *type,
int offset)
{
[ snip ]
v = allocate_value (ftype);
if (sym)
{
VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
}
else
[ snip ]
It's been a while since I submitted/completed a patch here. It'd be
relatively easy to add simple checks to stop the segfault (ie. check for
null, do something else). But, would that be the right method or just a
pointless patch?
--
David Lecomber <david@lecomber.net>