Skip to content

Commit

Permalink
Add annotate_ignore_thread_sanitizer_guard class
Browse files Browse the repository at this point in the history
Summary:
Add `annotate_ignore_thread_sanitizer_guard` class.

(Note: this ignores all push blocking failures!)

Reviewed By: yfeldblum

Differential Revision: D18045913

fbshipit-source-id: 39113e8df3deef3374a3c44246bc55a156bc4d8d
  • Loading branch information
dmm-fb authored and facebook-github-bot committed Oct 22, 2019
1 parent 023744f commit 509999e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
11 changes: 2 additions & 9 deletions folly/detail/AtFork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,8 @@ class AtForkList {
// so we just enable ignores for everything
// while handling the child callbacks
// This might still be an issue if we do not exec right away
annotate_ignore_reads_begin(__FILE__, __LINE__);
annotate_ignore_writes_begin(__FILE__, __LINE__);
annotate_ignore_sync_begin(__FILE__, __LINE__);

auto reenableAnnotationsGuard = folly::makeGuard([] {
annotate_ignore_reads_end(__FILE__, __LINE__);
annotate_ignore_writes_end(__FILE__, __LINE__);
annotate_ignore_sync_end(__FILE__, __LINE__);
});
annotate_ignore_thread_sanitizer_guard g(__FILE__, __LINE__);

auto& tasks = instance().tasks;
for (auto& task : tasks) {
task.child();
Expand Down
26 changes: 26 additions & 0 deletions folly/synchronization/SanitizeThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,30 @@ FOLLY_ALWAYS_INLINE static void annotate_ignore_sync_end(const char* f, int l) {
detail::annotate_ignore_sync_end_impl(f, l);
}
}

class annotate_ignore_thread_sanitizer_guard {
public:
annotate_ignore_thread_sanitizer_guard(const char* file, int line)
: file_(file), line_(line) {
annotate_ignore_reads_begin(file_, line_);
annotate_ignore_writes_begin(file_, line_);
annotate_ignore_sync_begin(file_, line_);
}

annotate_ignore_thread_sanitizer_guard(
const annotate_ignore_thread_sanitizer_guard&) = delete;
annotate_ignore_thread_sanitizer_guard& operator=(
const annotate_ignore_thread_sanitizer_guard&) = delete;

~annotate_ignore_thread_sanitizer_guard() {
annotate_ignore_reads_end(file_, line_);
annotate_ignore_writes_end(file_, line_);
annotate_ignore_sync_end(file_, line_);
}

private:
const char* file_;
int line_;
};

} // namespace folly

0 comments on commit 509999e

Please # to comment.