[thread-safety] remove custom compare for AccessListMap

Reviewed By: ngorogiannis

Differential Revision: D5929912

fbshipit-source-id: b26a9fc
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent 3c09ae953d
commit 14d0e2a786

@ -1071,19 +1071,7 @@ let analyze_procedure {Callbacks.proc_desc; tenv; summary} =
-> summary ) -> summary )
else Summary.update_summary empty_post summary else Summary.update_summary empty_post summary
module AccessListMap = Caml.Map.Make (struct module AccessListMap = Caml.Map.Make (ThreadSafetyDomain.Access)
type t = ThreadSafetyDomain.Access.t
(* TODO -- keep this compare to satisfy the order of tests, consider using Raw.compare *)
let compare access1 access2 =
let open ThreadSafetyDomain in
match (access1, access2) with
| ( (Access.Read access_path1 | Write access_path1)
, (Access.Read access_path2 | Write access_path2) )
-> List.compare AccessPath.compare_access (snd access_path1) (snd access_path2)
| _
-> Access.compare access1 access2
end)
let get_current_class_and_threadsafe_superclasses tenv pname = let get_current_class_and_threadsafe_superclasses tenv pname =
match pname with match pname with

@ -46,6 +46,14 @@ class Basic {
int get5() { return get_private_suspiciously_read(); } int get5() { return get_private_suspiciously_read(); }
void write_array_under_lock_ok(char* arr1) {
mutex_.lock();
arr1[2] = 'c';
mutex_.unlock();
}
int read_array_outside_lock_ok(char* arr2, int i) { return arr2[i]; }
private: private:
int well_guarded; int well_guarded;
int suspiciously_read; int suspiciously_read;

@ -28,8 +28,8 @@ class Arrays {
name1[2] = 4; name1[2] = 4;
} }
// we'll report this because name1 and name2 may alias // although name1 and name2 may alias, we have no reason to think that they will. don't report
int arrayParameterReadBad(int[] name2) { int FN_arrayParameterReadBad(int[] name2) {
return name2[2]; return name2[2];
} }

@ -14,7 +14,6 @@ codetoanalyze/java/threadsafety/Annotations.java, void Annotations.read_off_UI_t
codetoanalyze/java/threadsafety/Annotations.java, void ThreadSafeAlias.threadSafeAliasBad1(), 1, THREAD_SAFETY_VIOLATION, [access to `codetoanalyze.java.checkers.ThreadSafeAlias.field`] codetoanalyze/java/threadsafety/Annotations.java, void ThreadSafeAlias.threadSafeAliasBad1(), 1, THREAD_SAFETY_VIOLATION, [access to `codetoanalyze.java.checkers.ThreadSafeAlias.field`]
codetoanalyze/java/threadsafety/Annotations.java, void ThreadSafeAlias.threadSafeAliasBad2(), 1, THREAD_SAFETY_VIOLATION, [access to `codetoanalyze.java.checkers.ThreadSafeAlias.field`] codetoanalyze/java/threadsafety/Annotations.java, void ThreadSafeAlias.threadSafeAliasBad2(), 1, THREAD_SAFETY_VIOLATION, [access to `codetoanalyze.java.checkers.ThreadSafeAlias.field`]
codetoanalyze/java/threadsafety/Arrays.java, String Arrays.readWriteRaceBad(String), 4, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,access to `Arrays.strArr1.[_]`,<Beginning of write trace>,access to `Arrays.strArr1.[_]`] codetoanalyze/java/threadsafety/Arrays.java, String Arrays.readWriteRaceBad(String), 4, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,access to `Arrays.strArr1.[_]`,<Beginning of write trace>,access to `Arrays.strArr1.[_]`]
codetoanalyze/java/threadsafety/Arrays.java, int Arrays.arrayParameterReadBad(int[]), 1, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,access to `[_]`,<Beginning of write trace>,access to `[_]`]
codetoanalyze/java/threadsafety/Arrays.java, void Arrays.arrayParameterWriteBad(int[]), 1, THREAD_SAFETY_VIOLATION, [access to `[_]`] codetoanalyze/java/threadsafety/Arrays.java, void Arrays.arrayParameterWriteBad(int[]), 1, THREAD_SAFETY_VIOLATION, [access to `[_]`]
codetoanalyze/java/threadsafety/Arrays.java, void Arrays.writeWriteRaceBad(String), 1, THREAD_SAFETY_VIOLATION, [access to `Arrays.strArr1.[_]`] codetoanalyze/java/threadsafety/Arrays.java, void Arrays.writeWriteRaceBad(String), 1, THREAD_SAFETY_VIOLATION, [access to `Arrays.strArr1.[_]`]
codetoanalyze/java/threadsafety/Builders.java, Builders$Obj Builders.buildThenMutateBad(Builders$Obj), 2, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,call to Builders$Obj$Builder Builders$Obj$Builder.setFromObj(Builders$Obj),access to `codetoanalyze.java.checkers.Builders$Obj.g`,<Beginning of write trace>,access to `codetoanalyze.java.checkers.Builders$Obj.g`] codetoanalyze/java/threadsafety/Builders.java, Builders$Obj Builders.buildThenMutateBad(Builders$Obj), 2, THREAD_SAFETY_VIOLATION, [<Beginning of read trace>,call to Builders$Obj$Builder Builders$Obj$Builder.setFromObj(Builders$Obj),access to `codetoanalyze.java.checkers.Builders$Obj.g`,<Beginning of write trace>,access to `codetoanalyze.java.checkers.Builders$Obj.g`]

Loading…
Cancel
Save