2003-05-28 05:23:25

by Ryan Anderson

[permalink] [raw]
Subject: sparse errors

I'm not totally grokking how sparse is put together yet, but I've got
this:

Some symbols with type SYM_NODE are getting ctype->base_type==NULL,
causing a segfault in type_difference:422. (If I work around that one,
there's another spot at line 680. I started to follow what was going on
a bit at that point and realized they were probably symptoms, not the
actual bug, so I stopped working around it.)

I've got a config against bk-current that will trigger this in
fs/cramfs/uncompress.c attached in case it helps any.

Oh, BTW, the way you have struct ctype_sym declared inside struct symbol
confuses the crap out of gdb, but gcc appears to like it, so... *shrug*.

Should this be cc:ed to linux-kernel, or do you have another place in
mind?

--

Ryan Anderson
sometimes Pug Majere


Attachments:
(No filename) (791.00 B)
2.5.70-config (32.83 kB)
Download all attachments

2003-05-28 14:03:44

by Linus Torvalds

[permalink] [raw]
Subject: Re: sparse errors


On Wed, 28 May 2003, Ryan Anderson wrote:
>
> I'm not totally grokking how sparse is put together yet, but I've got
> this:
>
> Some symbols with type SYM_NODE are getting ctype->base_type==NULL,

This means they have no type at all, either because of a parse error, or
because the lazy evaluation hasn't evaluated it yet (ie it was a tad _too_
lazy).

> causing a segfault in type_difference:422. (If I work around that one,
> there's another spot at line 680. I started to follow what was going on
> a bit at that point and realized they were probably symptoms, not the
> actual bug, so I stopped working around it.)

Right.

The first thing to do is to see where it happens, in gdb do

up (to get to compatible_assignment_types)
p expr->pos (to get where in the soruce file it is)

it's triggered in cramfs_uncompress_block():

zlib_inflateReset(&stream);

on "stream", and the problem _seems_ to be that the target type for the
function call comparison is non-existent.

And that, in turn, seems to be because of the old K&R style function
prototype due to

#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif

and check not defining STDC.

It appears to be fixed by just adding -DSTDC to the check command line, to
make zlib use ANSI prototypes.

In short: sparse doesn't handle K&R function declarations very well,
although clearly it shouldn't have segfaulted (it should have warned about
it). I don't know why it didn't warn.

> Oh, BTW, the way you have struct ctype_sym declared inside struct symbol
> confuses the crap out of gdb, but gcc appears to like it, so... *shrug*.

Yeah, gdb is crap when it comes to anonymous structures, but I can't live
without them these days, so..

> Should this be cc:ed to linux-kernel, or do you have another place in
> mind?

It probably shouldn't be CC'd to linux-kernel, but there isn't any other
place either.

Linus

2003-05-28 14:21:58

by Carl-Daniel Hailfinger

[permalink] [raw]
Subject: Re: sparse errors

Linus Torvalds wrote:
> On Wed, 28 May 2003, Ryan Anderson wrote:
>
>>I'm not totally grokking how sparse is put together yet, but I've got
>>this:
[...]
>>Should this be cc:ed to linux-kernel, or do you have another place in
>>mind?
>
>
> It probably shouldn't be CC'd to linux-kernel, but there isn't any other
> place either.
>
> Linus

Maybe create a new list:

[email protected]

or something like that.


Carl-Daniel

2003-05-28 14:26:40

by Linus Torvalds

[permalink] [raw]
Subject: Re: sparse errors


On Wed, 28 May 2003, Ryan Anderson wrote:
>
> Some symbols with type SYM_NODE are getting ctype->base_type==NULL,
> causing a segfault in type_difference:422.

Fixed like this, causing the proper warning..

Linus

---
# This is a BitKeeper generated patch for the following project:
# Project Name: TSCT - The Silly C Tokenizer
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.345 -> 1.346
# parse.c 1.97 -> 1.98
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/05/28 [email protected] 1.346
# Check whether a parameter declaration is a type before trying
# to parse it as a type.
# --------------------------------------------
#
diff -Nru a/parse.c b/parse.c
--- a/parse.c Wed May 28 07:38:53 2003
+++ b/parse.c Wed May 28 07:38:53 2003
@@ -886,6 +886,10 @@
break;
}

+ if (!lookup_type(token)) {
+ warn(token->pos, "non-ANSI parameter list");
+ break;
+ }
token = parameter_declaration(token, &sym);
/* Special case: (void) */
if (!*list && !sym->ident && sym->ctype.base_type == &void_ctype)

2003-05-28 14:36:46

by Dave Jones

[permalink] [raw]
Subject: Re: sparse errors

On Wed, May 28, 2003 at 04:35:13PM +0200, Carl-Daniel Hailfinger wrote:

> > It probably shouldn't be CC'd to linux-kernel, but there isn't any other
> > place either.
> Maybe create a new list:
>
> [email protected]
>
> or something like that.

[email protected] has been used in the past for discussion
of such things a few times.

Dave