Title: [249064] trunk/Source/WTF
- Revision
- 249064
- Author
- cdu...@apple.com
- Date
- 2019-08-23 13:31:08 -0700 (Fri, 23 Aug 2019)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (249063 => 249064)
--- trunk/Source/WTF/ChangeLog 2019-08-23 20:23:21 UTC (rev 249063)
+++ trunk/Source/WTF/ChangeLog 2019-08-23 20:31:08 UTC (rev 249064)
@@ -1,3 +1,23 @@
+2019-08-23 Chris Dumez <cdu...@apple.com>
+
+ 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):
+
2019-08-21 Jiewen Tan <jiewen_...@apple.com>
[WebAuthn] Support NFC authenticators for iOS
Modified: trunk/Source/WTF/wtf/MainThread.h (249063 => 249064)
--- trunk/Source/WTF/wtf/MainThread.h 2019-08-23 20:23:21 UTC (rev 249063)
+++ trunk/Source/WTF/wtf/MainThread.h 2019-08-23 20:31:08 UTC (rev 249064)
@@ -54,6 +54,7 @@
WTF_EXPORT_PRIVATE bool isMainThread();
WTF_EXPORT_PRIVATE bool isMainThreadIfInitialized();
+WTF_EXPORT_PRIVATE bool isMainThreadInitialized();
WTF_EXPORT_PRIVATE bool canAccessThreadLocalDataForThread(Thread&);
Modified: trunk/Source/WTF/wtf/RefCounted.h (249063 => 249064)
--- trunk/Source/WTF/wtf/RefCounted.h 2019-08-23 20:23:21 UTC (rev 249063)
+++ trunk/Source/WTF/wtf/RefCounted.h 2019-08-23 20:31:08 UTC (rev 249064)
@@ -91,7 +91,8 @@
RefCountedBase()
: m_refCount(1)
#if !ASSERT_DISABLED
- , m_isOwnedByMainThread(isMainThread())
+ , m_isOwnedByMainThread(isMainThreadIfInitialized())
+ , m_areThreadingChecksEnabled(isMainThreadInitialized())
#endif
#if CHECK_REF_COUNTED_LIFECYCLE
, m_deletionHasBegun(false)
@@ -105,7 +106,7 @@
#if !ASSERT_DISABLED
if (hasOneRef()) {
// Likely an ownership transfer across threads that may be safe.
- m_isOwnedByMainThread = isMainThread();
+ m_isOwnedByMainThread = isMainThreadIfInitialized();
} else if (areThreadingChecksEnabledGlobally && m_areThreadingChecksEnabled) {
// If you hit this assertion, it means that the RefCounted object was ref/deref'd
// from both the main thread and another in a way that is likely concurrent and unsafe.
Modified: trunk/Source/WTF/wtf/cocoa/MainThreadCocoa.mm (249063 => 249064)
--- trunk/Source/WTF/wtf/cocoa/MainThreadCocoa.mm 2019-08-23 20:23:21 UTC (rev 249063)
+++ trunk/Source/WTF/wtf/cocoa/MainThreadCocoa.mm 2019-08-23 20:31:08 UTC (rev 249064)
@@ -181,6 +181,11 @@
return isMainThread();
}
+bool isMainThreadInitialized()
+{
+ return true;
+}
+
bool isUIThread()
{
return pthread_main_np();
@@ -239,6 +244,11 @@
return pthread_equal(pthread_self(), mainThreadPthread);
}
+bool isMainThreadInitialized()
+{
+ return mainThreadEstablishedAsPthreadMain || mainThreadPthread;
+}
+
#endif // USE(WEB_THREAD)
} // namespace WTF
Modified: trunk/Source/WTF/wtf/generic/MainThreadGeneric.cpp (249063 => 249064)
--- trunk/Source/WTF/wtf/generic/MainThreadGeneric.cpp 2019-08-23 20:23:21 UTC (rev 249063)
+++ trunk/Source/WTF/wtf/generic/MainThreadGeneric.cpp 2019-08-23 20:31:08 UTC (rev 249064)
@@ -92,6 +92,11 @@
return isMainThread();
}
+bool isMainThreadInitialized()
+{
+ return true;
+}
+
void scheduleDispatchFunctionsOnMainThread()
{
// Use a RunLoop::Timer instead of RunLoop::dispatch() to be able to use a different priority and
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes