From: Pavel Roskin <proski@gnu.org>
To: Christopher Li <sparse@chrisli.org>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [RFC PATCH] Fix crash in linearize_compound_statement()
Date: Tue, 08 Apr 2008 01:14:17 -0400 [thread overview]
Message-ID: <1207631657.3209.13.camel@rd> (raw)
In-Reply-To: <70318cbf0804071455g2f15e136qab225063f7faa89f@mail.gmail.com>
On Mon, 2008-04-07 at 14:55 -0700, Christopher Li wrote:
> On Mon, Apr 7, 2008 at 1:45 PM, Pavel Roskin <proski@gnu.org> wrote:
> > static int x;
> > static inline void foo(void)
> > {
> > if (x)
> > x = 1;
> > }
> > static void bar(void)
> > {
> > foo();
> > }
> > static typeof(bar) quux;
> >
> >
> > The crash happens in linearize_compound_statement(), and I believe that
> > the reason is incorrect access to phi_node->phi_list without making sure
> > that phi_node->opcode is OP_PHI. When processing the above program,
> > phi_node->phi_list can be OP_INLINED_CALL.
>
> No, that is not the root cause. The root cause is you feed sparse with
> bad input. typeof(bar) will give you a type of a function. Sparse just let
> quux have the base type of bar function body. That is just so wrong.
I know. And the source that was doing it is fixed long ago.
> > I understand very little in sparse code, and I have no idea what kind of
> > fallback is needed when phi_node->opcode is not OP_PHI.
> >
> > But this patch fixes the crash:
>
> As I said before, this is not the right fix. Wish it not get applied.
I should have been more clear. Last time I was carried away by some
strange messages about "return" and labels, which seemed really weird to
me, but less so after your explanation.
This example is made from the same original source, but this time I
concentrated on the crash, because that's the thing that cannot be
justified by any bad code.
> I agree sparse should not assert on it, but not like this.
I don't quite understand why sparse is getting in this situation, but
I'm quite confident from seeing other code that phi_node->phi_list is
invalid if phi_node->opcode is not OP_PHI, and should not be accessed.
I'd rather see sparse tripping an assert and crashing before it happens
rather than see it interpreting some other data as phi_list and crashing
randomly while iterating over that bogus list.
> You should at least fix it from the typeof(bar) side, instead of try
> to linearize
> the same function twice.
That's fixed, of course. And many other problems are fixed too, some of
which are user visible. I really appreciate the usefulness of sparse.
All I'm trying to do now is to have that crash fixed, after which I
would be glad to forget the ugly code that caused it.
--
Regards,
Pavel Roskin
next prev parent reply other threads:[~2008-04-08 5:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-07 20:45 [RFC PATCH] Fix crash in linearize_compound_statement() Pavel Roskin
2008-04-07 21:55 ` Christopher Li
2008-04-08 5:14 ` Pavel Roskin [this message]
2008-04-08 6:05 ` Christopher Li
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=1207631657.3209.13.camel@rd \
--to=proski@gnu.org \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
/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;
as well as URLs for NNTP newsgroup(s).