[PATCH] Division by zero

Anders Rönnholm Anders.Ronnholm at evidente.se
Mon Aug 11 23:58:26 PDT 2014


Hi Jordan,

I don't know if I have the time to change division by zero right away but I can make the dereference check CFG-based. Do you have an example of a CFG-based checker? I don't know how to make those.

//Anders

From: Jordan Rose [mailto:jordan_rose at apple.com]
Sent: den 21 juli 2014 19:40
To: Anders Rönnholm
Cc: cfe-commits at cs.uiuc.edu; Daniel Marjamäki; Anna Zaks
Subject: Re: [PATCH] Division by zero

So, Anna brought up that the check as implemented is very nearly path-independent, i.e. it only depends on flow-sensitive properties of the CFG. The path-sensitivity is buying us very little; it catches this case:

int y = x;
int div = z / y;
if (x) { ...}

But also warns here, which doesn't necessarily make sense:

int foo(int x, int y, int z) {
        int div = z / y;
        if (x) return div;
        return 0;
}

foo(a, a, b); // only coincidentally the same symbol

What would you think about turning this (and/or the null dereference check) into a CFG-based check instead? We lose the first example (and cases where inlining would help), but fix the second, and very possibly speed up analysis. CFG analysis is also more capable of proving that something happens on all paths rather than just some, since that's just propagating information along the graph.

Jordan


On Jul 10, 2014, at 9:55 , Anders Rönnholm <Anders.Ronnholm at evidente.se<mailto:Anders.Ronnholm at evidente.se>> wrote:


Great, no problem. I'll move forward with my dereference then check patch now that this one is commited, which will be pretty similar.

//Anders

.......................................................................................................................
Anders Rönnholm Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile:                    +46 (0)70 912 42 54
E-mail:                    Anders.Ronnholm at evidente.se<mailto:Anders.Ronnholm at evidente.se>

www.evidente.se<http://www.evidente.se>

________________________________________
Från: Jordan Rose [jordan_rose at apple.com]
Skickat: den 10 juli 2014 18:20
Till: Anders Rönnholm
Cc: cfe-commits at cs.uiuc.edu<mailto:cfe-commits at cs.uiuc.edu>; Daniel Marjamäki
Ämne: Re: [PATCH] Division by zero

Thank you for going through so many rounds of review on this. Committed in r212731! (The one change I made was to reset the test in isZero to use assume instead of assumeDual, now that my confusion has been fixed.)

Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140812/ab43f0e8/attachment.html>


More information about the cfe-commits mailing list