⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249064 in webkit


Ignore:
Timestamp:
Aug 23, 2019, 1:31:08 PM (7 years ago)
Author:
Chris Dumez
Message:

Regression(r248533) Assertion hit in isMainThread() for some clients using WTF because the main thread is not initialized
https://bugs.webkit.org/show_bug.cgi?id=201083

Reviewed by Alex Christensen.

An assertion is hit in isMainThread() for some clients using WTF because the main thread is not initialized, since r248533.
Clients can work around this by calling WTF::initializeMainThread() before using WTF but it seems unfortunate to force them
to do so. I propose we disable the assertion until the main thread is initialized.

  • wtf/MainThread.h:
  • wtf/RefCounted.h:

(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):

  • wtf/cocoa/MainThreadCocoa.mm:

(WTF::isMainThreadInitialized):

  • wtf/generic/MainThreadGeneric.cpp:

(WTF::isMainThreadInitialized):

Location:
trunk/Source/WTF
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r249059 r249064  
     12019-08-23  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(r248533) Assertion hit in isMainThread() for some clients using WTF because the main thread is not initialized
     4        https://bugs.webkit.org/show_bug.cgi?id=201083
     5
     6        Reviewed by Alex Christensen.
     7
     8        An assertion is hit in isMainThread() for some clients using WTF because the main thread is not initialized, since r248533.
     9        Clients can work around this by calling WTF::initializeMainThread() before using WTF but it seems unfortunate to force them
     10        to do so. I propose we disable the assertion until the main thread is initialized.
     11
     12        * wtf/MainThread.h:
     13        * wtf/RefCounted.h:
     14        (WTF::RefCountedBase::RefCountedBase):
     15        (WTF::RefCountedBase::applyRefDerefThreadingCheck const):
     16        * wtf/cocoa/MainThreadCocoa.mm:
     17        (WTF::isMainThreadInitialized):
     18        * wtf/generic/MainThreadGeneric.cpp:
     19        (WTF::isMainThreadInitialized):
     20
    1212019-08-21  Jiewen Tan  <jiewen_tan@apple.com>
    222
  • trunk/Source/WTF/wtf/MainThread.h

    r247461 r249064  
    5555WTF_EXPORT_PRIVATE bool isMainThread();
    5656WTF_EXPORT_PRIVATE bool isMainThreadIfInitialized();
     57WTF_EXPORT_PRIVATE bool isMainThreadInitialized();
    5758
    5859WTF_EXPORT_PRIVATE bool canAccessThreadLocalDataForThread(Thread&);
  • trunk/Source/WTF/wtf/RefCounted.h

    r248544 r249064  
    9292        : m_refCount(1)
    9393#if !ASSERT_DISABLED
    94         , m_isOwnedByMainThread(isMainThread())
     94        , m_isOwnedByMainThread(isMainThreadIfInitialized())
     95        , m_areThreadingChecksEnabled(isMainThreadInitialized())
    9596#endif
    9697#if CHECK_REF_COUNTED_LIFECYCLE
     
    106107        if (hasOneRef()) {
    107108            // Likely an ownership transfer across threads that may be safe.
    108             m_isOwnedByMainThread = isMainThread();
     109            m_isOwnedByMainThread = isMainThreadIfInitialized();
    109110        } else if (areThreadingChecksEnabledGlobally && m_areThreadingChecksEnabled) {
    110111            // If you hit this assertion, it means that the RefCounted object was ref/deref'd
  • trunk/Source/WTF/wtf/cocoa/MainThreadCocoa.mm

    r243795 r249064  
    182182}
    183183
     184bool isMainThreadInitialized()
     185{
     186    return true;
     187}
     188
    184189bool isUIThread()
    185190{
     
    240245}
    241246
     247bool isMainThreadInitialized()
     248{
     249    return mainThreadEstablishedAsPthreadMain || mainThreadPthread;
     250}
     251
    242252#endif // USE(WEB_THREAD)
    243253
  • trunk/Source/WTF/wtf/generic/MainThreadGeneric.cpp

    r248546 r249064  
    9393}
    9494
     95bool isMainThreadInitialized()
     96{
     97    return true;
     98}
     99
    95100void scheduleDispatchFunctionsOnMainThread()
    96101{
Note: See TracChangeset for help on using the changeset viewer.