From: Pavel Roskin <proski@gnu.org>
To: linux-sparse@vger.kernel.org
Subject: Sparse crash when mixing int and enum in ternary operator
Date: Mon, 08 Mar 2010 20:24:32 -0500 [thread overview]
Message-ID: <1268097872.16227.10.camel@mj> (raw)
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);
}
Here's the gdb trace:
Starting program: /home/proski/bin/sparse kind.c
kind.c:9:12: warning: mixing different enum types
Program received signal SIGSEGV, Segmentation fault.
0x00000000004328bf in do_show_type (sym=0x3, name=0x7fffffffdda0) at show-parse.c:242
242 if (!sym || (sym->type != SYM_NODE && sym->type != SYM_ARRAY &&
(gdb) p sym
$1 = (struct symbol *) 0x3
(gdb) up
#1 0x0000000000432e95 in show_typename (sym=0x7ffff7f99190) at show-parse.c:379
379 do_show_type(sym, &name);
(gdb) p sym
$2 = (struct symbol *) 0x7ffff7f99190
(gdb) p *sym
$3 = {type = SYM_ENUM, namespace = NS_NONE, used = 0 '\0', attr = 0 '\0',
enum_member = 0 '\0', bound = 0 '\0', pos = {type = 42, stream = 0, newline = 0,
whitespace = 0, pos = 0, line = 90177666, noexpand = 0}, endpos = {type = 9, stream = 0,
newline = 0, whitespace = 0, pos = 0, line = 2012974384, noexpand = 1}, ident = 0x0,
next_id = 0x7ffff7f99250, replace = 0x7ffff7fdaa20, scope = 0x0, {same_symbol = 0x0,
next_subobject = 0x0}, op = 0x3, {{expansion = 0x901700082, arglist = 0x668380,
used_in = 0x0}, {handler = 0x901700082, normal = 6718336}, {offset = 38678823042,
bit_size = 6718336, bit_offset = 0, arg_count = 0, variadic = 0, initialized = 0,
examined = 0, expanding = 0, evaluated = 0, string = 0, designated_init = 0,
array_size = 0x0, ctype = {modifiers = 140737353844496, alignment = 140737353984512,
contexts = 0x0, as = 0, base_type = 0x3}, arguments = 0x902400082, stmt = 0x668380,
symbol_list = 0x0, inline_stmt = 0x7ffff7fb8c50, inline_symbol_list = 0x7ffff7fdaa60,
initializer = 0x0, ep = 0x0, value = 3, definition = 0x905600082}}, {
bb_target = 0x668380, aux = 0x668380, {kind = -128 '\200', visited = 1 '\1'}},
pseudo = 0x0}
(gdb)
sym->ctype.base_type is 0x3, so sym becomes 0x3 after the first
iteration in do_show_type().
--
Regards,
Pavel Roskin
next reply other threads:[~2010-03-09 1:24 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-09 1:24 Pavel Roskin [this message]
2010-03-09 5:43 ` Sparse crash when mixing int and enum in ternary operator Christopher Li
2010-03-09 13:46 ` Kamil Dudka
2010-03-09 18:26 ` Pavel Roskin
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=1268097872.16227.10.camel@mj \
--to=proski@gnu.org \
--cc=linux-sparse@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.