[LockConsistency] Do not merge read/write with container read/write

Summary: We were conflating reads/writes with container reads/writes that created false positives.

Reviewed By: sblackshear

Differential Revision: D6232768

fbshipit-source-id: 39159cb
master
Daiva Naudziuniene 7 years ago committed by Facebook Github Bot
parent b2a3f3b8e4
commit ff475e43e4

@ -1524,10 +1524,11 @@ module SyntacticQuotientedAccessListMap : QuotientedAccessListMap = struct
let compare (x: t) (y: t) = let compare (x: t) (y: t) =
match (x, y) with match (x, y) with
| ( (Read ap1 | Write ap1 | ContainerRead (ap1, _) | ContainerWrite (ap1, _)) | (Read ap1 | Write ap1), (Read ap2 | Write ap2)
, (Read ap2 | Write ap2 | ContainerRead (ap2, _) | ContainerWrite (ap2, _)) ) -> | ( (ContainerRead (ap1, _) | ContainerWrite (ap1, _))
, (ContainerRead (ap2, _) | ContainerWrite (ap2, _)) ) ->
[%compare : (_var * Typ.t) * AccessPath.access list] ap1 ap2 [%compare : (_var * Typ.t) * AccessPath.access list] ap1 ap2
| InterfaceCall _, _ | _, InterfaceCall _ -> | (InterfaceCall _ | Read _ | Write _ | ContainerRead _ | ContainerWrite _), _ ->
RacerDDomain.Access.compare x y RacerDDomain.Access.compare x y
end) end)

@ -0,0 +1,31 @@
/*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <mutex>
#include <map>
namespace containers {
struct A {
int value;
};
struct B {
void access_container_and_contents_ok(int key, int value) {
int s = map.size();
mutex_.lock();
map[key].value = value;
}
private:
std::map<int, A> map;
std::mutex mutex_;
};
} // namespace containers
Loading…
Cancel
Save