2007-10-16 10:55:38

by Alexey Dobriyan

[permalink] [raw]
Subject: sparse breakage triggered by rcu_read_lock() lockdep annotations

FWIW, commit 851a67b825540a8e00c0be3ee25e4627ba8b133b
aka "lockdep: annotate rcu_read_{,un}lock{,_bh}"
causes sparse to trigger internal assertion in quite a few places over
allyesconfig run.

sparse: flow.c:805: rewrite_parent_branch: Assertion `changed' failed.

Trimmed down testcase:

void f(unsigned long ip);
static void g(void)
{
if (1) {
f(({ __label__ x; x: (unsigned long)&&x; }));
}
f(({ __label__ x; x: (unsigned long)&&x; }));
}

#0 0x4001c410 in __kernel_vsyscall ()
(gdb) bt
#0 0x4001c410 in __kernel_vsyscall ()
#1 0x40050701 in raise () from /lib/libc.so.6
#2 0x40051e38 in abort () from /lib/libc.so.6
#3 0x40049fcc in __assert_fail () from /lib/libc.so.6
#4 0x08064947 in pack_basic_blocks (ep=0x411a1c6c) at flow.c:812
#5 0x0805ffbf in linearize_symbol (sym=0x4103ec8c) at linearize.c:2154
#6 0x080492a3 in main (argc=Cannot access memory at address 0x274d) at sparse.c:266


2007-10-18 17:41:35

by Josh Triplett

[permalink] [raw]
Subject: Re: sparse breakage triggered by rcu_read_lock() lockdep annotations

Alexey Dobriyan wrote:
> FWIW, commit 851a67b825540a8e00c0be3ee25e4627ba8b133b
> aka "lockdep: annotate rcu_read_{,un}lock{,_bh}"
> causes sparse to trigger internal assertion in quite a few places over
> allyesconfig run.
>
> sparse: flow.c:805: rewrite_parent_branch: Assertion `changed' failed.
>
> Trimmed down testcase:
>
> void f(unsigned long ip);
> static void g(void)
> {
> if (1) {
> f(({ __label__ x; x: (unsigned long)&&x; }));
> }
> f(({ __label__ x; x: (unsigned long)&&x; }));
> }
>
> #0 0x4001c410 in __kernel_vsyscall ()
> (gdb) bt
> #0 0x4001c410 in __kernel_vsyscall ()
> #1 0x40050701 in raise () from /lib/libc.so.6
> #2 0x40051e38 in abort () from /lib/libc.so.6
> #3 0x40049fcc in __assert_fail () from /lib/libc.so.6
> #4 0x08064947 in pack_basic_blocks (ep=0x411a1c6c) at flow.c:812
> #5 0x0805ffbf in linearize_symbol (sym=0x4103ec8c) at linearize.c:2154
> #6 0x080492a3 in main (argc=Cannot access memory at address 0x274d) at sparse.c:266

Thanks for the detailed report. Looking into it now.

- Josh Triplett



Attachments:
signature.asc (252.00 B)
OpenPGP digital signature

2007-10-19 19:44:20

by Chris Li

[permalink] [raw]
Subject: Re: sparse breakage triggered by rcu_read_lock() lockdep annotations

Err,

Sparse does not support the local label syntax yet. It just treats the
second label "x:" as the same as the first one. Then the linearize
code gets serious confused when it saw one label get define in two
places.

The fix seems not trivial from the first look.

Chris

On 10/16/07, Alexey Dobriyan <[email protected]> wrote:
> FWIW, commit 851a67b825540a8e00c0be3ee25e4627ba8b133b
> aka "lockdep: annotate rcu_read_{,un}lock{,_bh}"
> causes sparse to trigger internal assertion in quite a few places over
> allyesconfig run.
>
> sparse: flow.c:805: rewrite_parent_branch: Assertion `changed' failed.
>
> Trimmed down testcase:
>
> void f(unsigned long ip);
> static void g(void)
> {
> if (1) {
> f(({ __label__ x; x: (unsigned long)&&x; }));
> }
> f(({ __label__ x; x: (unsigned long)&&x; }));
> }
>
> #0 0x4001c410 in __kernel_vsyscall ()
> (gdb) bt
> #0 0x4001c410 in __kernel_vsyscall ()
> #1 0x40050701 in raise () from /lib/libc.so.6
> #2 0x40051e38 in abort () from /lib/libc.so.6
> #3 0x40049fcc in __assert_fail () from /lib/libc.so.6
> #4 0x08064947 in pack_basic_blocks (ep=0x411a1c6c) at flow.c:812
> #5 0x0805ffbf in linearize_symbol (sym=0x4103ec8c) at linearize.c:2154
> #6 0x080492a3 in main (argc=Cannot access memory at address 0x274d) at sparse.c:266
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

2007-10-19 21:08:51

by Christopher Li

[permalink] [raw]
Subject: [PATCH] Re: sparse breakage triggered by rcu_read_lock() lockdep annotations

OK, I get a trivial fix after all. The test case is fixed now.
I haven't done much test otherwise.

See the patch attached.

Chris


On 10/19/07, Chris Li <[email protected]> wrote:
> Err,
>
> Sparse does not support the local label syntax yet. It just treats the
> second label "x:" as the same as the first one. Then the linearize
> code gets serious confused when it saw one label get define in two
> places.
>
> The fix seems not trivial from the first look.
>
> Chris
>
> On 10/16/07, Alexey Dobriyan <[email protected]> wrote:
> > FWIW, commit 851a67b825540a8e00c0be3ee25e4627ba8b133b
> > aka "lockdep: annotate rcu_read_{,un}lock{,_bh}"
> > causes sparse to trigger internal assertion in quite a few places over
> > allyesconfig run.
> >
> > sparse: flow.c:805: rewrite_parent_branch: Assertion `changed' failed.
> >
> > Trimmed down testcase:
> >
> > void f(unsigned long ip);
> > static void g(void)
> > {
> > if (1) {
> > f(({ __label__ x; x: (unsigned long)&&x; }));
> > }
> > f(({ __label__ x; x: (unsigned long)&&x; }));
> > }
> >
> > #0 0x4001c410 in __kernel_vsyscall ()
> > (gdb) bt
> > #0 0x4001c410 in __kernel_vsyscall ()
> > #1 0x40050701 in raise () from /lib/libc.so.6
> > #2 0x40051e38 in abort () from /lib/libc.so.6
> > #3 0x40049fcc in __assert_fail () from /lib/libc.so.6
> > #4 0x08064947 in pack_basic_blocks (ep=0x411a1c6c) at flow.c:812
> > #5 0x0805ffbf in linearize_symbol (sym=0x4103ec8c) at linearize.c:2154
> > #6 0x080492a3 in main (argc=Cannot access memory at address 0x274d) at sparse.c:266
> >
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
> > the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>


Attachments:
(No filename) (1.83 kB)
local-label (1.64 kB)
Download all attachments

2007-10-21 03:34:38

by Josh Triplett

[permalink] [raw]
Subject: Re: [PATCH] Re: sparse breakage triggered by rcu_read_lock() lockdep annotations

Christopher Li wrote:
> OK, I get a trivial fix after all. The test case is fixed now.
> I haven't done much test otherwise.
>
> See the patch attached.

Nice work Chris! Patch applied and pushed out.

I may roll an 0.4.1 release in the near future to fix kernel
builds with Sparse.

- Josh Triplett



Attachments:
signature.asc (252.00 B)
OpenPGP digital signature