diff options
author | junov <junov@chromium.org> | 2015-12-23 08:21:32 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-23 16:22:42 +0000 |
commit | 3e471195b0826a8b8228fefd378930f65c2671b0 (patch) | |
tree | d707fac84175e8dd1996f214d49b1558394fe8d8 /skia | |
parent | f9b06043ddd56b8bd27eb642fd1389b09cb2a2ed (diff) | |
download | chromium_src-3e471195b0826a8b8228fefd378930f65c2671b0.zip chromium_src-3e471195b0826a8b8228fefd378930f65c2671b0.tar.gz chromium_src-3e471195b0826a8b8228fefd378930f65c2671b0.tar.bz2 |
Fix TSAN error in skia/chromium ref count debug checks
Using std::atomic to make debug checks thread safe.
BUG=509693
R=senorblanco@chromium.org
Committed: https://crrev.com/0d030275667855c06be6cfc2ac10fb434d7ed771
Cr-Commit-Position: refs/heads/master@{#363274}
Review URL: https://codereview.chromium.org/1494633002
Cr-Commit-Position: refs/heads/master@{#366750}
Diffstat (limited to 'skia')
-rw-r--r-- | skia/BUILD.gn | 4 | ||||
-rw-r--r-- | skia/config/sk_ref_cnt_ext_debug.h | 14 |
2 files changed, 15 insertions, 3 deletions
diff --git a/skia/BUILD.gn b/skia/BUILD.gn index 3403417..1b38d80 100644 --- a/skia/BUILD.gn +++ b/skia/BUILD.gn @@ -278,6 +278,9 @@ config("skia_library_config") { component("skia") { sources = [ # Chrome sources. + "config/SkUserConfig.h", + "config/sk_ref_cnt_ext_debug.h", + "config/sk_ref_cnt_ext_release.h", "ext/SkDiscardableMemory_chrome.cc", "ext/SkMemory_new_handler.cpp", "ext/analysis_canvas.cc", @@ -441,6 +444,7 @@ component("skia") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ + ":skia_config", ":skia_library_config", "//build/config/compiler:no_chromium_code", ] diff --git a/skia/config/sk_ref_cnt_ext_debug.h b/skia/config/sk_ref_cnt_ext_debug.h index b2b66ad..78a39a3 100644 --- a/skia/config/sk_ref_cnt_ext_debug.h +++ b/skia/config/sk_ref_cnt_ext_debug.h @@ -9,23 +9,31 @@ #error Only one SkRefCnt should be used. #endif +#include <atomic> + // Alternate implementation of SkRefCnt for Chromium debug builds class SK_API SkRefCnt : public SkRefCntBase { public: - SkRefCnt() : flags_(0) {} - void ref() const { SkASSERT(flags_ != AdoptionRequired_Flag); SkRefCntBase::ref(); } + SkRefCnt(); + ~SkRefCnt() override; + void ref() const { SkASSERT(flags_.load() != AdoptionRequired_Flag); SkRefCntBase::ref(); } void adopted() const { flags_ |= Adopted_Flag; } void requireAdoption() const { flags_ |= AdoptionRequired_Flag; } void deref() const { SkRefCntBase::unref(); } private: + enum { Adopted_Flag = 0x1, AdoptionRequired_Flag = 0x2, }; - mutable int flags_; + mutable std::atomic<int> flags_; }; +inline SkRefCnt::SkRefCnt() : flags_(0) { } + +inline SkRefCnt::~SkRefCnt() { } + // Bootstrap for Blink's WTF::RefPtr namespace WTF { |