From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Xan Phung <xan.phung@gmail.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: PATCH: domtree_build() creates extraneous bb->doms entries
Date: Thu, 23 Jan 2020 20:27:26 +0100 [thread overview]
Message-ID: <20200123192726.hiownrizgbkwpekk@ltop.local> (raw)
In-Reply-To: <CAO6moYtTsA8niRvL135+OMXDjAEnGEGMf8kG+CYgq+YDKPi4UQ@mail.gmail.com>
On Thu, Jan 23, 2020 at 04:27:41PM +0800, Xan Phung wrote:
> Hi, I use Sparse's domtree_build() as the basis of my C implementation of
> the "Relooper" algorithm. I notice domtree_build appears to have a "memory
> leak" (this is an oversimplification of the problem, but not far off the
> truth).
>
> Specifically, each time domtree_build gets called, extraneous/duplicated
> child nodes get left in the bb->doms ptrlist. This is because the existing
> children are not cleared from bb->doms ptr list before rebuilding it. (If
> you want to reproduce this problem, I can supply a demo of it comprising a
> test input source file and a modified test-linearized.c, which calls
> domtree_build repeatedly and reports the memory allocation stats).
>
> In addition to consuming memory, the extraneous child nodes cause problems
> with my Relooper algorithm (as it results in a malformed dominance tree
> when walking down bb->doms).
Yes, indeed. The leak is one thing but the correctness is another one.
> The following 3 line patch fixes this problem:
Yes, that should do it. Thank you.
For me to take your patch would you mind to add your Signed-off-by,
certifying that you wrote the patch? Details can be found, for example,
at https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin
-- Luc
next parent reply other threads:[~2020-01-23 19:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAO6moYtTsA8niRvL135+OMXDjAEnGEGMf8kG+CYgq+YDKPi4UQ@mail.gmail.com>
2020-01-23 19:27 ` Luc Van Oostenryck [this message]
[not found] ` <CAO6moYti-1npHSaL8ibH9gDOSPCsnR=ufWrOCQyEBidSn2rRnQ@mail.gmail.com>
2020-01-28 23:06 ` PATCH: domtree_build() creates extraneous bb->doms entries Luc Van Oostenryck
2020-01-29 11:25 ` PATCH: sparse_add_switch() for backends to register new switches into main parsing table Xan Phung
2020-01-30 6:49 ` Luc Van Oostenryck
2020-01-30 14:33 ` Xan Phung
2020-01-31 6:52 ` Luc Van Oostenryck
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=20200123192726.hiownrizgbkwpekk@ltop.local \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=xan.phung@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