diff --git a/infer/documentation/issues/GUARDEDBY_VIOLATION.md b/infer/documentation/issues/GUARDEDBY_VIOLATION.md new file mode 100644 index 000000000..16314b5aa --- /dev/null +++ b/infer/documentation/issues/GUARDEDBY_VIOLATION.md @@ -0,0 +1,16 @@ +A field annotated with `@GuardedBy` is being accessed by a call-chain that starts at a non-private method without synchronization. + +Example: + +```java +class C { + @GuardedBy("this") + String f; + + void foo(String s) { + f = s; // unprotected access here + } +} +``` + +Action: Protect the offending access by acquiring the lock indicated by the `@GuardedBy(...)`. diff --git a/infer/src/base/IssueType.ml b/infer/src/base/IssueType.ml index 7ce20575d..42fe5d992 100644 --- a/infer/src/base/IssueType.ml +++ b/infer/src/base/IssueType.ml @@ -575,6 +575,7 @@ let _global_variable_initialized_with_function_or_method_call = let guardedby_violation_racerd = register_from_string Warning ~id:"GUARDEDBY_VIOLATION" ~hum:"GuardedBy Violation" RacerD + ~user_documentation:[%blob "../../documentation/issues/GUARDEDBY_VIOLATION.md"] let impure_function = register_from_string ~id:"IMPURE_FUNCTION" Error Impurity