This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] mdebugread.c (psymtab_to_symtab_1): assert that 'fh' is not null
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Michael Snyder <msnyder at vmware dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Sun, 6 Mar 2011 15:23:37 +0100
- Subject: Re: [RFA] mdebugread.c (psymtab_to_symtab_1): assert that 'fh' is not null
- References: <4D71648B.1090101@vmware.com>
On Fri, 04 Mar 2011 23:15:39 +0100, Michael Snyder wrote:
> This occurs along a path where fh *could* be null, and then we
> dereference it.
I agree there is a bug.
> + gdb_assert (fh);
[...]
> parse_external (ext_ptr, fh->fBigendian,
> pst->section_offsets, pst->objfile);
But I find as even a worse bug to introduce such an assertion without any
comment there.
I at least myself perceive any assertions that the programmer thinks such
invariant is valid there. That invariant says that if its negation happens
then the programmer was wrong.
If there is a known bug you have found and you just do not intend to fix it
now I find introducing such an assertion as misleading. The reader then
assumes such invariant and can do additional wrong conclusions from it.
In such case there should be primarily a "FIXME" comment, best even to
reference a filed a Bug. There can be also an assertion there but the "FIXME"
I find essential there.
Thanks,
Jan