Summary: Lambdas are essentially private (but are not marked as such in Infer), so we should only report on their non-private callers. Meanwhile, add a test to document that access propagation to those callers is currently broken. Reviewed By: da319 Differential Revision: D25944811 fbshipit-source-id: ef8ca6d9cmaster
parent
759fddc7e8
commit
7b8145b8bc
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
class Lambdas {
|
||||||
|
public:
|
||||||
|
void race_in_lambda_even_without_call_ok() {
|
||||||
|
auto lambda_with_sync = [&]() {
|
||||||
|
mutex_.lock();
|
||||||
|
f = 0;
|
||||||
|
mutex_.unlock();
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// access propagation to callees does not currently work
|
||||||
|
int FN_race_in_lambda_bad() {
|
||||||
|
auto lambda_with_sync = [&]() { return g; };
|
||||||
|
|
||||||
|
return lambda_with_sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_under_lock(int value) {
|
||||||
|
mutex_.lock();
|
||||||
|
g = value;
|
||||||
|
mutex_.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int f;
|
||||||
|
int g;
|
||||||
|
std::mutex mutex_;
|
||||||
|
};
|
Loading…
Reference in new issue