Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Michael Snyder <msnyder@vmware.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	       Doug Evans <dje@google.com>
Subject: Re: [RFA] off by one array reference in i386-low.c/i386_show_dr
Date: Sun, 27 Feb 2011 21:41:00 -0000	[thread overview]
Message-ID: <20110227213601.GA21759@host1.dyn.jankratochvil.net> (raw)
In-Reply-To: <4D6AC1C3.10508@vmware.com>

On Sun, 27 Feb 2011 22:27:31 +0100, Michael Snyder wrote:
> Jan Kratochvil wrote:
> >Hi Michael,
> >On Sat, 26 Feb 2011 23:52:23 +0100, Michael Snyder wrote:
> >>--- i386-low.c	1 Jan 2011 15:33:24 -0000	1.5
> >>+++ i386-low.c	26 Feb 2011 22:48:38 -0000
> >/* A macro to loop over all debug registers.  */
> >#define ALL_DEBUG_REGISTERS(i)  for (i = 0; i < DR_NADDR; i++)
> >>@@ -195,7 +195,7 @@ i386_show_dr (struct i386_debug_reg_stat
> >  ALL_DEBUG_REGISTERS(i)
> >    {
> >      printf_unfiltered ("\
> >> \tDR%d: addr=0x%s, ref.count=%d  DR%d: addr=0x%s, ref.count=%d\n",
> >> 	      i, paddress (state->dr_mirror[i]),
> >> 	      state->dr_ref_count[i],
> >>-	      i + 1, paddress (state->dr_mirror[i + 1]),
> >>+	      i + 1, paddress (state->dr_mirror[i]),
> >> 	      state->dr_ref_count[i + 1]);
> >>       i++;
> >>     }
> >
> >->
> >	CONTROL (DR7): 0000000000090101          STATUS (DR6): 0000000000004000
> >	DR0: addr=0x0000000001c31f30, ref.count=1  DR1: addr=0x0000000000000000, ref.count=0
> >	DR2: addr=0x0000000000000000, ref.count=0  DR3: addr=0x0000000000000000, ref.count=0
> >
> >I do not see a bug there; still it could be better commented.
> 
> The bug is that when "i" is 3, "i + 1" is 4, and the array only runs
> from 0 to 3.

But "i" is never 3.  "i" is 0 during the first cycle and 2 during the second
cycle.  And then the for cycle ends.  There is no 1 and there is no 3.


Regards,
Jan


  reply	other threads:[~2011-02-27 21:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-26 23:24 Michael Snyder
2011-02-27 16:47 ` Jan Kratochvil
2011-02-27 21:33   ` Michael Snyder
2011-02-27 21:41     ` Jan Kratochvil [this message]
2011-02-27 21:50     ` Mark Kettenis
2011-02-27 22:05       ` Michael Snyder
2011-02-27 17:01 ` Pedro Alves

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=20110227213601.GA21759@host1.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=msnyder@vmware.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