Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@cygnus.com>
To: Jason Molenda <jason-swarelist@molenda.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: Minor off-by-one error in command_line_handler
Date: Wed, 27 Mar 2002 09:40:00 -0000	[thread overview]
Message-ID: <3CA203AC.2090005@cygnus.com> (raw)
In-Reply-To: <20020327000106.A24311@molenda.com>

> The other problem is with the ALL_BLOCK_SYMBOLS macro.  It looks
> like this
> 
> /* Macro to loop through all symbols in a block BL.
>    i counts which symbol we are looking at, and sym points to the current
>    symbol.  */
> #define ALL_BLOCK_SYMBOLS(bl, i, sym)                   \
>         for ((i) = 0, (sym) = BLOCK_SYM ((bl), (i));    \
>              (i) < BLOCK_NSYMS ((bl));                  \
>              ++(i), (sym) = BLOCK_SYM ((bl), (i)))
> 
> Where the block structure (BL) ends with an array of pointers to
> symbols.  The third expression in the for statement increments the
> index variable and reads the address at the i'th element of the
> bl->sym[] array.
> 
> So when a block has 2 symbols, bl->sym[0] and bl->sym[1] contain
> values.  On the last evaluation of this loop, i is pre-incremented
> from 1 to 2 and the statement 'sym = bl->nsym[2]' is done - we're
> reading one element past the end of the array.
> 
> The invalid memory we just read is not used -- the conditional
> expression is then evaluated and the loop exits.  The only way
> I can see this causing a problem is on a system where reading
> that unallocated word of memory would cause a segfault.  Unless
> other people have heard complaints about gdb 5.1 doing so, I
> don't think this is worth worrying about. 

Yes I'd agree. Perhaphs create a very non-critical bug report for this one.

Andrew




  parent reply	other threads:[~2002-03-27 17:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-27  0:01 Jason Molenda
2002-03-27  8:34 ` Andrew Cagney
2002-03-27 10:11   ` Elena Zannoni
2002-03-27 11:54     ` Andreas Schwab
2002-03-27 13:31       ` Elena Zannoni
2002-03-27 13:21         ` Andreas Schwab
2002-03-27  9:40 ` Andrew Cagney [this message]
2002-03-28 23:54 ` Daniel Jacobowitz
2002-03-30 21:05   ` Andrew Cagney
2002-03-30 21:08     ` Daniel Jacobowitz
2002-04-03 19:27       ` Andrew Cagney
2002-04-09 13:52     ` Daniel Jacobowitz

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=3CA203AC.2090005@cygnus.com \
    --to=ac131313@cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jason-swarelist@molenda.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