Changeset 250765 in webkit
- Timestamp:
- Oct 4, 2019 8:15:02 PM (5 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r250763 r250765 1 2019-10-04 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r250762. 4 https://bugs.webkit.org/show_bug.cgi?id=202609 5 6 Broke JSC tests by breaking refCount check in 7 DropAllLocks::DropAllLocks (Requested by rniwa on #webkit). 8 9 Reverted changeset: 10 11 "Make a ThreadSafeRefCounted object safe to ref & deref inside 12 its destructor" 13 https://bugs.webkit.org/show_bug.cgi?id=201576 14 https://trac.webkit.org/changeset/250762 15 1 16 2019-10-04 Ryosuke Niwa <rniwa@webkit.org> 2 17 -
trunk/Source/WTF/wtf/ThreadSafeRefCounted.h
r250762 r250765 33 33 namespace WTF { 34 34 35 #if defined(NDEBUG) && !ENABLE(SECURITY_ASSERTIONS)36 #define CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE 037 #else38 #define CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE 139 #endif40 41 35 class ThreadSafeRefCountedBase { 42 36 WTF_MAKE_NONCOPYABLE(ThreadSafeRefCountedBase); … … 45 39 ThreadSafeRefCountedBase() = default; 46 40 47 #if CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE48 ~ThreadSafeRefCountedBase()49 {50 // When this ThreadSafeRefCounted object is a part of another object, derefBase() is never called on this object.51 m_deletionHasBegun = true;52 }53 #endif54 55 41 void ref() const 56 42 { 57 #if CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE58 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun);59 #endif60 43 ++m_refCount; 61 44 } … … 63 46 bool hasOneRef() const 64 47 { 65 #if CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE66 ASSERT(!m_deletionHasBegun);67 #endif68 48 return refCount() == 1; 69 49 } … … 78 58 bool derefBase() const 79 59 { 80 ASSERT(m_refCount); 81 82 #if CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE 83 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); 84 #endif 85 86 if (UNLIKELY(!--m_refCount)) { 87 // Setting m_refCount to 1 here prevents double delete within the destructor but not from another thread 88 // since such a thread could have ref'ed this object long after it had been deleted. See webkit.org/b/201576. 89 m_refCount = 1; 90 #if CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE 91 m_deletionHasBegun = true; 92 #endif 93 return true; 94 } 95 96 return false; 60 return !--m_refCount; 97 61 } 98 62 99 63 private: 100 64 mutable std::atomic<unsigned> m_refCount { 1 }; 101 102 #if CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE103 mutable std::atomic<bool> m_deletionHasBegun { false };104 #endif105 65 }; 106 66
Note: See TracChangeset
for help on using the changeset viewer.