You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
879 B

This is an error reported on C++ and Objective C classes whenever:
- Some class method directly uses locking primitives (not transitively).
- It has a public method which writes to some member `x` while holding a lock.
- It has a public method which reads `x` without holding a lock.
The above may happen through a chain of calls. Above, `x` may also be a
container (an array, a vector, etc).
### Fixing Lock Consistency Violation reports
- Avoid the offending access (most often the read). Of course, this may not be
possible.
- Use synchronization to protect the read, by using the same lock protecting the
corresponding write.
- Make the method doing the read access private. This should silence the
warning, since Infer looks for a pair of non-private methods. Objective-C:
Infer considers a method as private if it's not exported in the header-file
interface.