Fun with Linux 2.6.21-rc1
Hello!
The current sparse reports many errors with Linux 2.6.21-rc1. There are screenfuls of errors for every file. I have reduced one of them to this simple file:
struct st {
char c;
} __attribute__ ((aligned(2)));struct st s1;
struct st s2;
$ sparse test.c test.c:5:18: error: Expected ( after asm test.c:5:18: error: got s2 test.c:5:20: error: Expected ) after asm test.c:5:20: error: got ; builtin:0:0: error: expected declaration
The strange thing is that there is no "asm" here at all.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 11 lines · Pavel Roskin
Hello!
The current sparse reports many errors with Linux 2.6.21-rc1. There are screenfuls of errors for every file. I have reduced one of them to this simple file:
struct st { char c; } __attribute__ ((aligned(2)));struct st s1;
struct st s2;
P.S. The breakage has nothing to do to Linux changes. It was caused by the patch called "Make the ptrlist using the sparse allocator". Undoing the patch fixes the problem.
Signature · 2 lines
Regards, Pavel Roskin
Christopher Li
maintainerQuoted 4 lines · Pavel Roskin
P.S. The breakage has nothing to do to Linux changes. It was caused by the patch called "Make the ptrlist using the sparse allocator". Undoing the patch fixes the problem.
No, that was not it. The bug does not trigger if I remove "-O" or remove the recent struct attribute patch.
You make me guilt for 5 mins. But the real bugs is match_idents did not end with NULL.
This patch should fix it:
Chris
Fix a bug that match_idents forget to end with NULL
Pavel Roskin manage to hit this bug with
struct st {
char c;
} __attribute__ ((aligned(2)));struct st s1;
struct st s2;
parse.c +1 -1
@@ -861,7 +861,7 @@ static struct token *handle_attributes(sapply_ctype (token->pos, &thistype, ctype);continue ; } -if (match_idents (token, &asm_ident, &__asm_ident, &__asm___ident)) { +if (match_idents (token, &asm_ident, &__asm_ident, &__asm___ident,NULL )) {struct expression *expr; token =expect (token->next,'(' ,"after asm" ); token =parse_expression (token->next, &expr);
Quoted 11 lines · Christopher Li
Quoted 4 lines · Pavel Roskin
P.S. The breakage has nothing to do to Linux changes. It was caused by the patch called "Make the ptrlist using the sparse allocator". Undoing the patch fixes the problem.No, that was not it. The bug does not trigger if I remove "-O" or remove the recent struct attribute patch.
You make me guilt for 5 mins. But the real bugs is
match_identsdid not end with NULL.
I understand your patch triggered a bug that was sitting there for more than two years. That's quite rare. Sorry for assuming your guilt.
Quoted 1 line
This patch should fix it:
Yes, it's working. Thank you!
Signature · 2 lines
Regards, Pavel Roskin
Josh Triplett
Appliedexposing __attribute__ portability macros in lib.h; any objections?
In reply to Christopher LiQuoted 1 line · Christopher Li
Fix a bug that
match_identsforget to end with NULL
[...]
Quoted 1 line
Signed-off-by Christopher Li <[email protected]>
[...]
parse.c static struct token *handle_attributes(s · line 864
Quoted 2 lines
parse.c +1
-1-if (match_idents (token, &asm_ident, &__asm_ident, &__asm___ident)) { +if (match_idents (token, &asm_ident, &__asm_ident, &__asm___ident,NULL )) {
Applied.
I'd also like to apply a patch to use __attribute__((__sentinel__)) on match_idents, which would have caught this problem. In order to do so portably, I plan to add a portability macro SENTINEL_ATTR, like the FORMAT_ATTR macro currently in lib.h. However, lib.h currently defines FORMAT_ATTR, uses it for a few prototypes, and then undefines it. Any objections to defining SENTINEL_ATTR and leaving it defined (and probably doing the same for FORMAT_ATTR)? I don't think those would pollute the namespace any more than lib.h already does with position, verbose, info, and similar.
- Josh Triplett
Christopher Li
maintainerRe: exposing __attribute__ portability macros in lib.h; any objections?
Quoted 1 line · Josh Triplett
Applied.
Thanks!
Quoted 10 lines
I'd also like to apply a patch to use __attribute__((__sentinel__)) on
match_idents, which would have caught this problem. In order to do so portably, I plan to add a portability macroSENTINEL_ATTR, like theFORMAT_ATTRmacro currently inlib.h. However,lib.hcurrently definesFORMAT_ATTR, uses it for a few prototypes, and then undefines it. Any objections to definingSENTINEL_ATTRand leaving it defined (and probably doing the same forFORMAT_ATTR)? I don't think those would pollute the namespace any more thanlib.halready does with position, verbose, info, and similar.
No objection for __sentinel__ per se. In the long run, I would like to get ride of match_idents completely. I want to define more parser operation function for pre-defined keywords. So it is driven by the symbol table rather than comparing the keyword one by one. It is a big change though.
Chris