Changeset 250765 in webkit


Ignore:
Timestamp:
Oct 4, 2019 8:15:02 PM (5 years ago)
Author:
rniwa@webkit.org
Message:

Unreviewed, rolling out r250762.
https://bugs.webkit.org/show_bug.cgi?id=202609

Broke JSC tests by breaking refCount check in
DropAllLocks::DropAllLocks (Requested by rniwa on #webkit).

Reverted changeset:

"Make a ThreadSafeRefCounted object safe to ref & deref inside
its destructor"
https://bugs.webkit.org/show_bug.cgi?id=201576
https://trac.webkit.org/changeset/250762

Patch by Commit Queue <commit-queue@webkit.org> on 2019-10-04

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r250763 r250765  
     12019-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
    1162019-10-04  Ryosuke Niwa  <rniwa@webkit.org>
    217
  • trunk/Source/WTF/wtf/ThreadSafeRefCounted.h

    r250762 r250765  
    3333namespace WTF {
    3434
    35 #if defined(NDEBUG) && !ENABLE(SECURITY_ASSERTIONS)
    36 #define CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE 0
    37 #else
    38 #define CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE 1
    39 #endif
    40 
    4135class ThreadSafeRefCountedBase {
    4236    WTF_MAKE_NONCOPYABLE(ThreadSafeRefCountedBase);
     
    4539    ThreadSafeRefCountedBase() = default;
    4640
    47 #if CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE
    48     ~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 #endif
    54 
    5541    void ref() const
    5642    {
    57 #if CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE
    58         ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun);
    59 #endif
    6043        ++m_refCount;
    6144    }
     
    6346    bool hasOneRef() const
    6447    {
    65 #if CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE
    66         ASSERT(!m_deletionHasBegun);
    67 #endif
    6848        return refCount() == 1;
    6949    }
     
    7858    bool derefBase() const
    7959    {
    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;
    9761    }
    9862
    9963private:
    10064    mutable std::atomic<unsigned> m_refCount { 1 };
    101 
    102 #if CHECK_THREAD_SAFE_REF_COUNTED_LIFECYCLE
    103     mutable std::atomic<bool> m_deletionHasBegun { false };
    104 #endif
    10565};
    10666
Note: See TracChangeset for help on using the changeset viewer.