This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] PthreadLock: Escape the pointers.
ClosedPublic

Authored by NoQ on Sep 13 2017, 9:16 AM.

Details

Summary

As usual, we need to invalidate mutex states when something may touch them. Implement this boilerplate for the thread lock checker.

The previous refactoring is handy for listing functions on which we don't need to invalidate mutex states because we model them instead.

Additionally, i don't invalidate mutex states when any system header function is called, unless the mutex is passed directly into it. The TODO here would be to model *all* system functions that may change mutex states, and then disable invalidation for the rest of them even if they take a mutex; that's what other checkers do.

Diff Detail

Event Timeline

xazax.hun added inline comments.Sep 21 2017, 1:44 AM
lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
594 ↗(On Diff #115053)

Wouldn't it be better to branch on IsLibraryFunction and in one branch iterate on Regions and in the other, iterate on ExplicitRegions?
That would avoid the possible quadratic explosion when lots of explicit regions are invalidated.

a.sidorin edited edge metadata.Nov 13 2017, 6:56 AM

Hi Artem. The patch looks mostly good, but I have an inline question.

lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
588 ↗(On Diff #115053)

Do we think that only system headers contain library functions? Shouldn't we use CheckerContext::isCLibraryFunction() instead?

This revision was not accepted when it landed; it landed in state Needs Review.Jan 24 2020, 7:45 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 24 2020, 7:45 AM