This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Don't crash on printing ConcreteInt of size >64 bits
ClosedPublic

Authored by a.sidorin on Apr 8 2018, 10:43 AM.

Details

Summary

Printing of ConcreteInts with size >64 bits resulted in assertion failure in get[Z|S]ExtValue() :getActiveBits() <= 64 && "Too many bits for uint64_t"' failed'. This patch fixes the issue.

Initial patch by Ivan Sidorenko (modified by A. Sidorin).

Diff Detail

Repository
rC Clang

Event Timeline

a.sidorin created this revision.Apr 8 2018, 10:43 AM
lib/StaticAnalyzer/Core/SVals.cpp
304

Given that getValue is accessed 6 times now, I would put it into a variable

305

Makes sense, another option would be to add a fast path to APInt::print?

test/Analysis/egraph-dump-int128.c
3 ↗(On Diff #141557)

At least on a mac, ViewExplodedGraph launches GraphViz.app.
Can we have a less invasive check? Wouldn't just dumping a value be sufficient?

george.karpenkov requested changes to this revision.Apr 9 2018, 10:58 AM
This revision now requires changes to proceed.Apr 9 2018, 10:58 AM
NoQ added inline comments.Apr 9 2018, 1:58 PM
test/Analysis/egraph-dump-int128.c
3 ↗(On Diff #141557)

Yeah, it just runs xdg-open on linux and open on mac, which often opens up a GUI viewer. That's not the behavior we want from automated tests.

I think you should use ExprInspection instead, and either dump the whole state with clang_analyzer_printState() or, even better, dump only the particular value with clang_analyzer_dump(...) - that way you'll be also capable of verifying the output.

Note that we actually don't have much tests for our dumps.

a.sidorin updated this revision to Diff 141869.Apr 10 2018, 9:40 AM
a.sidorin edited the summary of this revision. (Show Details)

After thinking a bit more, I have removed the FIXME at all: dumping SVal is an extremely rare event so this shouldn't affect the performance.

a.sidorin updated this revision to Diff 141870.Apr 10 2018, 9:42 AM

Renamed the test file.

I have removed the FIXME at all

👍

This revision is now accepted and ready to land.Apr 10 2018, 10:49 AM
a.sidorin closed this revision.Apr 23 2018, 8:47 AM

Closed with https://reviews.llvm.org/rC330605. Forgot to mention the Differential Revision, sorry.