[analyzer] PthreadLock: Escape the pointers.
Needs ReviewPublic

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

xazax.hun added inline comments.Sep 21 2017, 1:44 AM
lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
594

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.

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

lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
588

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