This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Assume escape is possible through system functions taking void*
ClosedPublic

Authored by zaks.anna on Oct 6 2015, 4:47 PM.

Details

Reviewers
dcoughlin
Summary

The analyzer assumes that system functions will not free memory or modify the arguments in other ways, so we assume that arguments do not escape when those are called. However, this may lead to false positive leak errors. For example, in code like this where the pointers added to the rb_tree are freed later on:

		struct alarm_event *e = calloc(1, sizeof(*e));

<snip>

		rb_tree_insert_node(&alarm_tree, e);

Add a heuristic to assume that calls to system functions taking void* arguments allow for pointer escape.

Diff Detail

Event Timeline

zaks.anna updated this revision to Diff 36679.Oct 6 2015, 4:47 PM
zaks.anna retitled this revision from to [analyzer] Assume escape is possible through system functions taking void*.
zaks.anna updated this object.
zaks.anna added a reviewer: dcoughlin.
zaks.anna added subscribers: xazax.hun, cfe-commits.
dcoughlin accepted this revision.Oct 6 2015, 6:15 PM
dcoughlin edited edge metadata.

Has a typo but otherwise LGTM.

include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
258

Did you consider using std::function<bool(QualType)> instead of a function pointer so that clients could use lambdas that capture to provide the condition?

test/Analysis/Inputs/system-header-simulator.h
85

Typo "strauctures"

This revision is now accepted and ready to land.Oct 6 2015, 6:15 PM
zaks.anna closed this revision.Nov 17 2015, 5:00 PM

Committed in r251449.