Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@vmware.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFA] mdebugread.c (psymtab_to_symtab_1): assert that 'fh' is not null
Date: Sun, 06 Mar 2011 18:54:00 -0000	[thread overview]
Message-ID: <4D73D67F.1030704@vmware.com> (raw)
In-Reply-To: <20110306142337.GB1895@host1.jankratochvil.net>

Jan Kratochvil wrote:
> 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.


All these recent submissions of mine are coming from running Coverity
on gdb.  In this case, Coverity reports that we checked the variable fh
for null (suggesting that we think null is possible), but then 
dereferenced it on an unchecked path.

I figured that triggering an assert was more gracefull than just
crashing on a null pointer dereference, and gives the user the chance
to recover.


  reply	other threads:[~2011-03-06 18:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-04 22:15 Michael Snyder
2011-03-06 16:17 ` Jan Kratochvil
2011-03-06 18:54   ` Michael Snyder [this message]
2011-03-06 19:05     ` Jan Kratochvil
2011-03-07 16:53       ` Tom Tromey
2011-03-07 17:21         ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D73D67F.1030704@vmware.com \
    --to=msnyder@vmware.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox