Skip to content

Commit

Permalink
[thread-safety][c++] Do not record accesses to static locals
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jberdine authored and facebook-github-bot committed Oct 30, 2017
1 parent 149deb9 commit c2a67bb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion infer/src/concurrency/RacerD.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -1908,3 +1913,4 @@ let file_analysis {Callbacks.procedures} =
else (module MayAliasQuotientedAccessListMap) )
class_env))
(aggregate_by_class procedures)

0 comments on commit c2a67bb

Please sign in to comment.