From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33491 invoked by alias); 25 Oct 2017 02:24:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 33406 invoked by uid 89); 25 Oct 2017 02:24:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Oct 2017 02:24:13 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v9P2O4RV014472 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 24 Oct 2017 22:24:09 -0400 Received: by simark.ca (Postfix, from userid 112) id 8EC9F1E521; Tue, 24 Oct 2017 22:24:04 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 454E61E4F3; Tue, 24 Oct 2017 22:23:53 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Wed, 25 Oct 2017 02:24:00 -0000 From: Simon Marchi To: Patrick Frants Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Fix broken recursion detection when printing static members In-Reply-To: References: <20171024105535.13287-1-osscontribute@gmail.com> Message-ID: <318a8f60fd9bae60c1b25e3b5b0c05e8@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 25 Oct 2017 02:24:04 +0000 X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00753.txt.bz2 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