linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: Kamil Dudka <kdudka@redhat.com>
Cc: Christopher Li <sparse@chrisli.org>, linux-sparse@vger.kernel.org
Subject: Re: Sparse crash when mixing int and enum in ternary operator
Date: Tue, 09 Mar 2010 13:26:26 -0500	[thread overview]
Message-ID: <1268159186.23196.5.camel@mj> (raw)
In-Reply-To: <201003091446.50092.kdudka@redhat.com>

On Tue, 2010-03-09 at 14:46 +0100, Kamil Dudka wrote:
> On Tue March 9 2010 06:43:09 Christopher Li wrote:
> > On Mon, Mar 8, 2010 at 5:24 PM, Pavel Roskin <proski@gnu.org> wrote:
> > > Hello!
> > > 
> > > Sparse crashed when checking drivers/net/wireless/ath/ath9k/gpio.c in
> > > Linux.  I could reduce the crash to the following simple program:
> > > 
> > > enum kind {
> > >    GOOD
> > > };
> > > static void foo(enum kind k)
> > > {
> > > }
> > > static void bar(int ok, int k)
> > > {
> > >    foo(ok ? GOOD : k);
> > > }
> > 
> > Confirm. This is cause by the recent enum-warning patch. Without it the
> > sparse runs fine.
> 
> Thank both of you for tacking down the bug!
> 
> > Let me see if this is some thing easy to fix.
> 
> It's easy to fix as soon as I understand how EXPR_CONDITIONAL/EXPR_SELECT
> work in sparse.  A fix from scratch is attached, but I'll need more time
> for testing it and to write some extra test-cases.

Now sparse crashes on crypto/tcrypt.c, where it didn't crash before:

Core was generated by `sparse -D__linux__ -Dlinux -D__STDC__ -Dunix
-D__unix__ -Wbitwise -Wno-return-v'.
Program terminated with signal 11, Segmentation fault.
#0  0x0000000000408131 in warn_for_different_enum_types (expr=0x0,
typeb=0x7f3b69632850) at evaluate.c:248
248             struct position pos = expr->pos;
(gdb) p expr
$1 = (struct expression *) 0x0
(gdb) where
#0  0x0000000000408131 in warn_for_different_enum_types (expr=0x0,
typeb=0x7f3b69632850) at evaluate.c:248
#1  0x000000000040843c in do_warn_for_enum_conversions (expr=0x0,
type=0x7f3b69632850) at evaluate.c:332
#2  0x000000000040849d in warn_for_enum_conversions
(expr=0x7f3b690378d0, type=0x7f3b69632850) at evaluate.c:343
#3  0x00000000004084ee in cast_to (old=0x7f3b690378d0,
type=0x7f3b69632850) at evaluate.c:363
#4  0x000000000040b035 in compatible_assignment_types
(expr=0x7f3b690378d0, target=0x7f3b69632850, rp=0x7f3b6903bd38,
where=0x664a00 "argument 3") at evaluate.c:1465
#5  0x000000000040ccec in evaluate_arguments (f=0x7f3b696323f0,
fn=0x7f3b696324d0, head=0x7f3b6903bd10) at evaluate.c:2221
#6  0x000000000040e82f in evaluate_call (expr=0x7f3b690377d0) at
evaluate.c:2888
#7  0x000000000040efc5 in evaluate_expression (expr=0x7f3b690377d0) at
evaluate.c:3059
#8  0x0000000000409a07 in evaluate_conditional (expr=0x7f3b690377d0,
iterator=0) at evaluate.c:937
#9  0x000000000040a3ef in evaluate_conditional_expression
(expr=0x7f3b69037950) at evaluate.c:1176
#10 0x000000000040efd6 in evaluate_expression (expr=0x7f3b69037950) at
evaluate.c:3062
#11 0x000000000040f3ff in evaluate_return_expression
(stmt=0x7f3b69044980) at evaluate.c:3181
#12 0x000000000040fd5b in evaluate_statement (stmt=0x7f3b69044980) at
evaluate.c:3404
#13 0x000000000040fe3c in evaluate_statement (stmt=0x7f3b69044930) at
evaluate.c:3426
#14 0x000000000040f343 in evaluate_symbol (sym=0x7f3b690280f0) at
evaluate.c:3158
#15 0x000000000040f3a7 in evaluate_symbol_list (list=0x7f3b69c06710) at
evaluate.c:3171
#16 0x00000000004075f2 in sparse (filename=0x7fff22e43882
"/home/proski/src/linux-2.6/crypto/tcrypt.c") at lib.c:984
#17 0x0000000000401a1f in main (argc=65, argv=0x7fff22e42348) at
sparse.c:284
(gdb) up 2
#2  0x000000000040849d in warn_for_enum_conversions
(expr=0x7f3b690378d0, type=0x7f3b69632850) at evaluate.c:343
343
do_warn_for_enum_conversions(expr->cond_true, type);
(gdb) p expr->cond_true
$1 = (struct expression *) 0x0
(gdb) p expr->cond_false
$2 = (struct expression *) 0x7f3b6a387b10

-- 
Regards,
Pavel Roskin

  reply	other threads:[~2010-03-09 18:26 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-09  1:24 Sparse crash when mixing int and enum in ternary operator Pavel Roskin
2010-03-09  5:43 ` Christopher Li
2010-03-09 13:46   ` Kamil Dudka
2010-03-09 18:26     ` Pavel Roskin [this message]
2010-03-09 18:35     ` Pavel Roskin
2010-03-09 19:06       ` Kamil Dudka
2010-03-09 19:15         ` Josh Triplett
2010-03-09 20:11           ` Pavel Roskin
2010-03-09 20:29             ` Kamil Dudka
2010-03-09 23:30               ` Kamil Dudka
2010-03-10  1:09                 ` Pavel Roskin
2010-03-10 16:05                   ` Kamil Dudka
2010-03-10 20:27                     ` Pavel Roskin
2010-03-10 20:44                       ` Kamil Dudka
2010-03-10 21:03                       ` Kamil Dudka
2010-03-10 21:56                     ` Christopher Li
2010-03-13 17:22                       ` Kamil Dudka
2010-03-21 15:27                         ` Kamil Dudka
2010-03-24 10:07                           ` Christopher Li
2010-03-24 10:51                             ` Kamil Dudka
2010-03-27  9:16                             ` Kamil Dudka
2010-03-27  9:29                               ` Josh Triplett
2010-03-27  9:53                                 ` [PATCH] eliminate insane conversions from int to enum Kamil Dudka
2010-03-29 18:11                                   ` Christopher Li
2010-03-29 18:05                                 ` Sparse crash when mixing int and enum in ternary operator Christopher Li
2010-03-29 18:17                                   ` Kamil Dudka
2010-03-29 18:48                                     ` Christopher Li
2010-03-29 19:23                                       ` Kamil Dudka
2010-03-30  5:29                                         ` Pavel Roskin
2010-03-29 21:26                                   ` Josh Triplett

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=1268159186.23196.5.camel@mj \
    --to=proski@gnu.org \
    --cc=kdudka@redhat.com \
    --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).