From c2a67bb30024c464f56ee1ef6b7412fd2369f68a Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Mon, 30 Oct 2017 04:06:52 -0700 Subject: [PATCH] [thread-safety][c++] Do not record accesses to static locals Summary: The clang frontend translates static locals incorrectly, in the sense that the initializer is executed many times instead of once. This leads to false alarms in the concurrency analysis. This diff suppresses these by ignoring accesses to static locals. Reviewed By: sblackshear Differential Revision: D6182644 fbshipit-source-id: d8ca4c0 --- infer/src/concurrency/RacerD.ml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index 89bee8cf8..d3486d37b 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -375,6 +375,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct | _ -> false in + let is_static_access ((base: Var.t), _) = + match base with ProgramVar pvar -> Pvar.is_static_local pvar | _ -> false + in let rec add_field_accesses pre prefix_path access_acc = function | [] -> access_acc @@ -394,7 +397,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct in let add_access_ acc (base, accesses) = let base_access_path = (base, []) in - if List.is_empty accesses || OwnershipDomain.is_owned base_access_path ownership then acc + if List.is_empty accesses || OwnershipDomain.is_owned base_access_path ownership + || is_static_access base + then acc else let pre = match AccessPrecondition.make locks threads proc_data.pdesc with @@ -1908,3 +1913,4 @@ let file_analysis {Callbacks.procedures} = else (module MayAliasQuotientedAccessListMap) ) class_env)) (aggregate_by_class procedures) +