Skip to contentSkip to conversation

smatch update / 2.5.64 / kbugs.org

DISCUSSION dan carpenter 2 participants 3 messages Mar 7, 2003 – Mar 14, 2003

lore
Share & tools
lore
#0 lore raw

From: Oleg Drokin <[email protected]>

Quoted 5 lines
Quoted 2 lines

The smatch bugs for kernel 2.5.64 are up. The new url for the smatch bug database is http://kbugs.org.

Unfortunatelly the bug database does not work. I mean I cannot connect to it.

Crap... sorry about that, I screwed up.

Quoted 4 lines

This script can produce a lot less false positives with even more custom merge rules. Here's the diff that if run on fs/ext3/super.c from current bk tree, produces only one true bug. (your version from cvs produces one real bug and two false positives) (8 less hits on my default build).

I have uploaded your modifications to CVS. I'll use it on the next kernel release. The unfree.pl was just a few modifications to the deference_check.pl so your patch will cut down on the false positives with that also.

thanks,
dan carpenter

Signature · 6 lines
_______________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

Meet Singles
http://corp.mail.com/lavalife
#1 lore raw

Hello!

Quoted 5 lines · dan carpenter
Quoted 3 lines
Quoted 2 lines

The smatch bugs for kernel 2.5.64 are up. The new url for the smatch bug database is http://kbugs.org.

Unfortunatelly the bug database does not work. I mean I cannot connect to it.

Crap... sorry about that, I screwed up.

Quoted 8 lines
Quoted 4 lines

This script can produce a lot less false positives with even more custom merge rules. Here's the diff that if run on fs/ext3/super.c from current bk tree, produces only one true bug. (your version from cvs produces one real bug and two false positives) (8 less hits on my default build).

I have uploaded your modifications to CVS. I'll use it on the next kernel release. The unfree.pl was just a few modifications to the deference_check.pl so your patch will cut down on the false positives with that also.

Actually I think these free() checks can be extended a lot, it can detect memory leaks and so on.

I have preliminary working version here, but it was only barely tested (And not tested on real kernel at all). I will spend more time on it today and then send it in.
Incidentally this new version should also work on non-kernel code too, I think ;)
I think that tracking only negative/NULL returns is not the best way.
My current approach is to add several more states like "exported" which means that this value was added to externally visible variable. Then upon reaching return/end of function we can see if all the allocated stuff was freed or exported. Tricky part seems to correctly merge all these states from different branches of if steatements.

Also is anybody working on "redundant assignments" stuff as described in Standford guys papers?

Bye,
Oleg

#2 lore raw

Hello!

Quoted 1 line · Oleg Drokin

Actually I think these free() checks can be extended a lot, it can detect memory leaks and so on.

Ok, it took me awhile, but here is much extended version of unfree checker.
Now the biggest source of false positives is assignments to global variables and to arrays I have more complete list of problematic places at beginning of the script, in case anyone want to enhance it. Also it should now work with userspace code.
<shameless plug>Funnily enough, even though I started to work on this script hoping to find some deeply hidden bugs in reiserfs, I ended up finding bugs in other filesystems instead ;)</shameless plug>

It also requires this function in smatch.pm (I see that now you have changed set_state() to allow empty second argument, so it may be not that strictly needed now).

sub reset_state {
    my $name;
    my $i;

    $name = $_[0];

    foreach $state (@states){
        my $quotedname = quotemeta $name;
        my $temp = pop(@states);
        if ($state->{name} =~ /^$quotedname$/){
            $state->{state} = 0;
            $state->{start_line} = 0;
            return;
        }
        push @states, $temp;
    }
}

Bye,
Oleg