[racerd] disambiguate duplicate reports due to method overloading

Summary: Method overloading creates the potential for report duplication even though the reports are actually distinct.  Make the report message unique by not using shortened method names.

Reviewed By: jeremydubreil

Differential Revision: D8005862

fbshipit-source-id: 53d8ea0
master
Nikos Gorogiannis 7 years ago committed by Facebook Github Bot
parent 6f8bccb8fd
commit dde2000e75

@ -1035,9 +1035,9 @@ let report_unannotated_interface_violation tenv pdesc access thread reported_pna
let class_name = Typ.Procname.Java.get_class_name java_pname in let class_name = Typ.Procname.Java.get_class_name java_pname in
let make_description _ _ _ _ = let make_description _ _ _ _ =
F.asprintf F.asprintf
"Unprotected call to method of un-annotated interface %s. Consider annotating the class \ "Unprotected call to method %a of un-annotated interface %s. Consider annotating the \
with %a, adding a lock, or using an interface that is known to be thread-safe." class with %a, adding a lock, or using an interface that is known to be thread-safe."
class_name MF.pp_monospaced "@ThreadSafe" Typ.Procname.pp reported_pname class_name MF.pp_monospaced "@ThreadSafe"
in in
report_thread_safety_violation tenv pdesc ~make_description ~report_kind:UnannotatedInterface report_thread_safety_violation tenv pdesc ~make_description ~report_kind:UnannotatedInterface
access thread RacerDDomain.StabilityDomain.empty access thread RacerDDomain.StabilityDomain.empty
@ -1046,18 +1046,9 @@ let report_unannotated_interface_violation tenv pdesc access thread reported_pna
() ()
let pp_procname_short fmt = function
| Typ.Procname.Java java ->
F.fprintf fmt "%s.%s"
(Typ.Procname.Java.get_class_name java)
(Typ.Procname.Java.get_method java)
| pname ->
Typ.Procname.pp fmt pname
let make_unprotected_write_description pname final_sink_site initial_sink_site final_sink = let make_unprotected_write_description pname final_sink_site initial_sink_site final_sink =
Format.asprintf "Unprotected write. Non-private method %a%s %s %a outside of synchronization." Format.asprintf "Unprotected write. Non-private method %a%s %s %a outside of synchronization."
(MF.wrap_monospaced pp_procname_short) (MF.wrap_monospaced Typ.Procname.pp)
pname pname
(if CallSite.equal final_sink_site initial_sink_site then "" else " indirectly") (if CallSite.equal final_sink_site initial_sink_site then "" else " indirectly")
(if RacerDDomain.TraceElem.is_container_write final_sink then "mutates" else "writes to field") (if RacerDDomain.TraceElem.is_container_write final_sink then "mutates" else "writes to field")
@ -1083,7 +1074,7 @@ let make_read_write_race_description ~read_is_sync (conflict: reported_access) p
(MF.wrap_monospaced pp_conflict) conflict (MF.wrap_monospaced pp_conflict) conflict
in in
Format.asprintf "Read/Write race. Non-private method %a%s reads%s from %a. %s." Format.asprintf "Read/Write race. Non-private method %a%s reads%s from %a. %s."
(MF.wrap_monospaced pp_procname_short) (MF.wrap_monospaced Typ.Procname.pp)
pname pname
(if CallSite.equal final_sink_site initial_sink_site then "" else " indirectly") (if CallSite.equal final_sink_site initial_sink_site then "" else " indirectly")
(if read_is_sync then " with synchronization" else " without synchronization") (if read_is_sync then " with synchronization" else " without synchronization")
@ -1097,13 +1088,15 @@ let make_read_write_race_description ~read_is_sync (conflict: reported_access) p
type reported = type reported =
{ reported_sites: CallSite.Set.t { reported_sites: CallSite.Set.t
; reported_writes: Typ.Procname.Set.t ; reported_writes: Typ.Procname.Set.t
; reported_reads: Typ.Procname.Set.t } ; reported_reads: Typ.Procname.Set.t
; reported_unannotated_calls: Typ.Procname.Set.t }
let empty_reported = let empty_reported =
let reported_sites = CallSite.Set.empty in let reported_sites = CallSite.Set.empty in
let reported_writes = Typ.Procname.Set.empty in let reported_writes = Typ.Procname.Set.empty in
let reported_reads = Typ.Procname.Set.empty in let reported_reads = Typ.Procname.Set.empty in
{reported_sites; reported_reads; reported_writes} let reported_unannotated_calls = Typ.Procname.Set.empty in
{reported_sites; reported_reads; reported_writes; reported_unannotated_calls}
(** Report accesses that may race with each other. (** Report accesses that may race with each other.
@ -1137,7 +1130,8 @@ let empty_reported =
let report_unsafe_accesses (aggregated_access_map: reported_access list AccessListMap.t) = let report_unsafe_accesses (aggregated_access_map: reported_access list AccessListMap.t) =
let open RacerDDomain in let open RacerDDomain in
let open RacerDConfig in let open RacerDConfig in
let is_duplicate_report access pname {reported_sites; reported_writes; reported_reads} = let is_duplicate_report access pname
{reported_sites; reported_writes; reported_reads; reported_unannotated_calls} =
if Config.filtering then if Config.filtering then
CallSite.Set.mem (TraceElem.call_site access) reported_sites CallSite.Set.mem (TraceElem.call_site access) reported_sites
|| ||
@ -1147,7 +1141,7 @@ let report_unsafe_accesses (aggregated_access_map: reported_access list AccessLi
| Access.Read _ | Access.ContainerRead _ -> | Access.Read _ | Access.ContainerRead _ ->
Typ.Procname.Set.mem pname reported_reads Typ.Procname.Set.mem pname reported_reads
| Access.InterfaceCall _ -> | Access.InterfaceCall _ ->
false Typ.Procname.Set.mem pname reported_unannotated_calls
else false else false
in in
let update_reported access pname reported = let update_reported access pname reported =
@ -1161,7 +1155,10 @@ let report_unsafe_accesses (aggregated_access_map: reported_access list AccessLi
let reported_reads = Typ.Procname.Set.add pname reported.reported_reads in let reported_reads = Typ.Procname.Set.add pname reported.reported_reads in
{reported with reported_reads; reported_sites} {reported with reported_reads; reported_sites}
| Access.InterfaceCall _ -> | Access.InterfaceCall _ ->
reported let reported_unannotated_calls =
Typ.Procname.Set.add pname reported.reported_unannotated_calls
in
{reported with reported_unannotated_calls; reported_sites}
else reported else reported
in in
let report_unsafe_access {snapshot; threads; tenv; procdesc; wobbly_paths} accesses reported_acc = let report_unsafe_access {snapshot; threads; tenv; procdesc; wobbly_paths} accesses reported_acc =

Loading…
Cancel
Save