[racerd] consider ownership of interface calls

Summary: The main point here is to ignore owned interfaces when considering whether to warn about non-thread-safe calls.

Reviewed By: ezgicicek

Differential Revision: D25187775

fbshipit-source-id: c2a7ce89c
master
Nikos Gorogiannis 4 years ago committed by Facebook GitHub Bot
parent 9acdedeef8
commit 0105f280a3

@ -601,10 +601,10 @@ let pp fmt {threads; locks; accesses; ownership; attribute_map} =
let add_unannotated_call_access formals pname actuals loc (astate : t) = let add_unannotated_call_access formals pname actuals loc (astate : t) =
apply_to_first_actual actuals astate ~f:(fun receiver -> apply_to_first_actual actuals astate ~f:(fun receiver ->
let ownership = OwnershipDomain.get_owned receiver astate.ownership in
let access_opt = let access_opt =
(* FIXME this should use the ownership of the receiver! *)
AccessSnapshot.make_unannotated_call_access formals receiver pname astate.locks AccessSnapshot.make_unannotated_call_access formals receiver pname astate.locks
astate.threads Unowned loc astate.threads ownership loc
in in
{astate with accesses= AccessDomain.add_opt access_opt astate.accesses} ) {astate with accesses= AccessDomain.add_opt access_opt astate.accesses} )

@ -87,6 +87,21 @@ public class Dispatch {
UnannotatedInterface owned = new UnannotadedImplementation(); UnannotatedInterface owned = new UnannotadedImplementation();
privateCallUnnanotatedInterfaceOk(owned); privateCallUnnanotatedInterfaceOk(owned);
} }
UnannotatedInterface mUnannotated;
private void privateCallOk() {
mUnannotated.foo();
}
public void publicCallBad() {
privateCallOk();
}
public Dispatch() {
// this is OK even though public, since the object is owned
privateCallOk();
}
} }
class Some { class Some {

@ -53,7 +53,8 @@ codetoanalyze/java/racerd/Containers.java, codetoanalyze.java.checkers.Container
codetoanalyze/java/racerd/DeepOwnership.java, DeepOwnership.globalNotOwnedBad():void, 16, THREAD_SAFETY_VIOLATION, no_bucket, WARNING, [access to `DeepOwnership.global.next`] codetoanalyze/java/racerd/DeepOwnership.java, DeepOwnership.globalNotOwnedBad():void, 16, THREAD_SAFETY_VIOLATION, no_bucket, WARNING, [access to `DeepOwnership.global.next`]
codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.Dispatch.callUnannotatedInterfaceBad(codetoanalyze.java.checkers.UnannotatedInterface):void, 49, INTERFACE_NOT_THREAD_SAFE, no_bucket, WARNING, [Call to un-annotated interface method void UnannotatedInterface.foo()] codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.Dispatch.callUnannotatedInterfaceBad(codetoanalyze.java.checkers.UnannotatedInterface):void, 49, INTERFACE_NOT_THREAD_SAFE, no_bucket, WARNING, [Call to un-annotated interface method void UnannotatedInterface.foo()]
codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.Dispatch.callUnannotatedInterfaceIndirectBad(codetoanalyze.java.checkers.NotThreadSafe,codetoanalyze.java.checkers.UnannotatedInterface):void, 53, INTERFACE_NOT_THREAD_SAFE, no_bucket, WARNING, [call to void NotThreadSafe.notThreadSafeOk(UnannotatedInterface),Call to un-annotated interface method void UnannotatedInterface.foo()] codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.Dispatch.callUnannotatedInterfaceIndirectBad(codetoanalyze.java.checkers.NotThreadSafe,codetoanalyze.java.checkers.UnannotatedInterface):void, 53, INTERFACE_NOT_THREAD_SAFE, no_bucket, WARNING, [call to void NotThreadSafe.notThreadSafeOk(UnannotatedInterface),Call to un-annotated interface method void UnannotatedInterface.foo()]
codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.ThreadConfinedField.interfaceCallOnNormalFieldBad():void, 111, INTERFACE_NOT_THREAD_SAFE, no_bucket, WARNING, [Call to un-annotated interface method void UnannotatedInterface.foo()] codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.Dispatch.publicCallBad():void, 98, INTERFACE_NOT_THREAD_SAFE, no_bucket, WARNING, [call to void Dispatch.privateCallOk(),Call to un-annotated interface method void UnannotatedInterface.foo()]
codetoanalyze/java/racerd/Dispatch.java, codetoanalyze.java.checkers.ThreadConfinedField.interfaceCallOnNormalFieldBad():void, 126, INTERFACE_NOT_THREAD_SAFE, no_bucket, WARNING, [Call to un-annotated interface method void UnannotatedInterface.foo()]
codetoanalyze/java/racerd/GuardedByTests.java, codetoanalyze.java.infer.GuardedByOther.accessBad():void, 127, GUARDEDBY_VIOLATION, no_bucket, WARNING, [access to `this.x`] codetoanalyze/java/racerd/GuardedByTests.java, codetoanalyze.java.infer.GuardedByOther.accessBad():void, 127, GUARDEDBY_VIOLATION, no_bucket, WARNING, [access to `this.x`]
codetoanalyze/java/racerd/GuardedByTests.java, codetoanalyze.java.infer.GuardedByTests.interprocUnlockedWriteBad():void, 59, GUARDEDBY_VIOLATION, no_bucket, WARNING, [call to void GuardedByTests.privateUnlockedWriteOk(),access to `this.d`] codetoanalyze/java/racerd/GuardedByTests.java, codetoanalyze.java.infer.GuardedByTests.interprocUnlockedWriteBad():void, 59, GUARDEDBY_VIOLATION, no_bucket, WARNING, [call to void GuardedByTests.privateUnlockedWriteOk(),access to `this.d`]
codetoanalyze/java/racerd/GuardedByTests.java, codetoanalyze.java.infer.GuardedByTests.unlockedWriteBad():void, 35, GUARDEDBY_VIOLATION, no_bucket, WARNING, [access to `this.b`] codetoanalyze/java/racerd/GuardedByTests.java, codetoanalyze.java.infer.GuardedByTests.unlockedWriteBad():void, 35, GUARDEDBY_VIOLATION, no_bucket, WARNING, [access to `this.b`]

Loading…
Cancel
Save