Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Patrick Frants <osscontribute@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix broken recursion detection when printing static members
Date: Wed, 25 Oct 2017 02:24:00 -0000	[thread overview]
Message-ID: <318a8f60fd9bae60c1b25e3b5b0c05e8@polymtl.ca> (raw)
In-Reply-To: <CAEsN4Zsofk2R_5qBXH--PrKDOvk=i49cnY=5R8hn8nTTT2m3kg@mail.gmail.com>

On 2017-10-24 06:59, Patrick Frants wrote:
> I am so sorry, looks like git send-email removed the first N lines. 
> Here is
> the complete changelog:
> 
> Fix broken recursion detection when printing static members
> 
> Recursion detection for static members was broken. The implementation 
> uses
> a growing (and shrinking) obstack object to simulate a stack of 
> addresses
> (CORE_ADDR). Pushing addresses is implemented by calling 
> obstack_grow(),
> while popping is implemented by calling obstack_free(). The latter is
> problematic because obstack_free() expects a pointer to the base of an
> object. When popping elements of the stack however, obstack_free() was
> called with the new top, which potentially is not the same as the base 
> of
> the stack. This is unintended use and the effect is that 
> obstack->next_free
> and obstack->object_base members are assigned the value of the new top,
> which equals an empty stack. Summary: popping elements would always 
> result
> in an empty stack, which breaks the recursion detection.
> 
> The fix shrinks the stack using obstack_blank_fast() with a negative 
> value
> as described at the bottom of this page:
> https://gcc.gnu.org/onlinedocs/libiberty/Extra-Fast-Growing.html
> "You can use obstack_blank_fast with a “negative” size argument to make 
> the
> current object smaller. Just don’t try to shrink it beyond zero
> length—there’s no telling what will happen if you do that. Earlier 
> versions
> of obstacks allowed you to use obstack_blank to shrink objects. This 
> will
> no longer work."

Thanks for the nice description!

Simon


  reply	other threads:[~2017-10-25  2:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-24 10:55 Patrick Frants
2017-10-24 10:59 ` Patrick Frants
2017-10-25  2:24   ` Simon Marchi [this message]
2017-10-25  2:23 ` Simon Marchi
2017-10-25  7:11   ` osscontribute

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=318a8f60fd9bae60c1b25e3b5b0c05e8@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=osscontribute@gmail.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