[reporting] Report access path from the initial sink rather than the final sink.

Summary: In a thread safety report we used the access path from the final sink. This diffs change the report to include the expanded access path from the initial sink.

Reviewed By: sblackshear

Differential Revision: D6297848

fbshipit-source-id: 2386063
master
Daiva Naudziuniene 7 years ago committed by Facebook Github Bot
parent b9a56a6c52
commit e07a20ea6d

@ -1169,7 +1169,7 @@ let report_thread_safety_violation tenv pdesc ~make_description ~report_kind acc
let loc = CallSite.loc initial_sink_site in let loc = CallSite.loc initial_sink_site in
let ltr = make_trace ~report_kind path pdesc in let ltr = make_trace ~report_kind path pdesc in
(* what the potential bug is *) (* what the potential bug is *)
let description = make_description pname final_sink_site initial_sink_site final_sink in let description = make_description pname final_sink_site initial_sink_site initial_sink in
(* why we are reporting it *) (* why we are reporting it *)
let issue_type, explanation = get_reporting_explanation report_kind tenv pname thread in let issue_type, explanation = get_reporting_explanation report_kind tenv pname thread in
let error_message = F.sprintf "%s%s" description explanation in let error_message = F.sprintf "%s%s" description explanation in

@ -8,6 +8,8 @@ codetoanalyze/cpp/racerd/lock_guard.cpp, basics::LockGuard_get4, 0, LOCK_CONSIST
codetoanalyze/cpp/racerd/lock_guard.cpp, basics::LockGuard_test1, 2, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_read`,<Write trace>,access to `&this.suspiciously_read`] codetoanalyze/cpp/racerd/lock_guard.cpp, basics::LockGuard_test1, 2, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_read`,<Write trace>,access to `&this.suspiciously_read`]
codetoanalyze/cpp/racerd/lock_guard_with_scope.cpp, basics::LockGuardWithScope_get2, 3, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_written`,<Write trace>,access to `&this.suspiciously_written`] codetoanalyze/cpp/racerd/lock_guard_with_scope.cpp, basics::LockGuardWithScope_get2, 3, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_written`,<Write trace>,access to `&this.suspiciously_written`]
codetoanalyze/cpp/racerd/lock_guard_with_scope.cpp, basics::LockGuardWithScope_get4, 0, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_read`,<Write trace>,access to `&this.suspiciously_read`] codetoanalyze/cpp/racerd/lock_guard_with_scope.cpp, basics::LockGuardWithScope_get4, 0, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_read`,<Write trace>,access to `&this.suspiciously_read`]
codetoanalyze/cpp/racerd/reporting.cpp, reporting::Basic_call1, 1, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,call to reporting::Basic_test,access to `&xparam.x1.w`,<Write trace>,call to reporting::Basic_call1,call to reporting::Basic_test,access to `&xparam.x1.w`]
codetoanalyze/cpp/racerd/reporting.cpp, reporting::Basic_test_unlock, 0, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,call to reporting::Basic_call1,call to reporting::Basic_test,access to `&xparam.x1.w`,<Write trace>,call to reporting::Basic_call1,call to reporting::Basic_test,access to `&xparam.x1.w`]
codetoanalyze/cpp/racerd/unique_lock.cpp, basics::UniqueLock_get2, 3, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_written1`,<Write trace>,access to `&this.suspiciously_written1`] codetoanalyze/cpp/racerd/unique_lock.cpp, basics::UniqueLock_get2, 3, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_written1`,<Write trace>,access to `&this.suspiciously_written1`]
codetoanalyze/cpp/racerd/unique_lock.cpp, basics::UniqueLock_get2, 4, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_written2`,<Write trace>,access to `&this.suspiciously_written2`] codetoanalyze/cpp/racerd/unique_lock.cpp, basics::UniqueLock_get2, 4, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_written2`,<Write trace>,access to `&this.suspiciously_written2`]
codetoanalyze/cpp/racerd/unique_lock.cpp, basics::UniqueLock_get4, 1, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_read1`,<Write trace>,access to `&this.suspiciously_read1`] codetoanalyze/cpp/racerd/unique_lock.cpp, basics::UniqueLock_get4, 1, LOCK_CONSISTENCY_VIOLATION, [<Read trace>,access to `&this.suspiciously_read1`,<Write trace>,access to `&this.suspiciously_read1`]

@ -0,0 +1,40 @@
/*
* 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>
namespace reporting {
struct X {
int w;
X* x1;
};
class Basic {
public:
Basic() {}
void test(X& xparam) { xparam.x1->w++; }
void call1() {
test(x); // race
}
int test_lock() {
mutex_.lock();
call1();
}
int test_unlock() { call1(); }
private:
X x;
std::mutex mutex_;
};
} // namespace reporting
Loading…
Cancel
Save