This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Fix a crash by division by zero
ClosedPublic

Authored by takeshi-yoshimura on May 30 2015, 12:16 AM.

Details

Summary

When I conducted static analysis without core checkers, clang encountered
a crash by division by zero. The cause of the division-by-zero is
that BasicValueFactory::evalAPSInt() blindly operates divisions with
*any* known values. It means the SVal builder operates divisions even if
RHS value is zero. My fix is simply adding a RHS check before performing
the division in BasicValueFactory::evalAPSInt().

Diff Detail

Repository
rL LLVM

Event Timeline

takeshi-yoshimura retitled this revision from to [analyzer] Fix a crash by division by zero.
takeshi-yoshimura updated this object.
takeshi-yoshimura edited the test plan for this revision. (Show Details)
takeshi-yoshimura added a subscriber: Unknown Object (MLST).

I can reproduce using your testcode. It's a good catch. And the fix looks good to me. Does anybody else have any opinions?

danielmarjamaki accepted this revision.May 31 2015, 11:51 PM
danielmarjamaki added a reviewer: danielmarjamaki.
This revision is now accepted and ready to land.May 31 2015, 11:51 PM
takeshi-yoshimura edited edge metadata.

Thanks, danielmarjamaki. I found llvm-lit fails with the test code, so I updated it.

takeshi-yoshimura set the repository for this revision to rL LLVM.Jun 2 2015, 5:16 AM

Thanks!

Do you need help to commit this?

Does anybody else have comments?

Yes, could you commit this?

This revision was automatically updated to reflect the committed changes.

Thanks! I committed the changes with 240643.