Changeset 221083 in webkit
- Timestamp:
- Aug 23, 2017 10:41:39 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r221077 r221083 1 2017-08-23 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Race condition in StartWebThread causing crash 4 https://bugs.webkit.org/show_bug.cgi?id=175852 5 6 Reviewed by Mark Lam. 7 8 When starting web thread, the main thread waits for completion of web thread initialization 9 by using pthread_cond_t. However, the main thread may be woken up due to the existence of 10 the spurious wake up of pthread_cond_t. 11 12 Instead, we should use WTF::Lock and WTF::Condition. Since our StartWebThread already calls 13 WTF::initializeThreading, it is safe to use WTF::Lock and WTF::Condition. And our WTF::Condition 14 does not have the spurious wake up problem as described in Condition.h. 15 16 * platform/ios/wak/WebCoreThread.mm: 17 (RunWebThread): 18 (StartWebThread): 19 1 20 2017-08-23 Brent Fulgham <bfulgham@apple.com> 2 21 -
trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm
r220186 r221083 128 128 static CFRunLoopObserverRef mainRunLoopAutoUnlockObserver; 129 129 130 static pthread_mutex_t startupLock = PTHREAD_MUTEX_INITIALIZER;131 static pthread_cond_t startupCondition = PTHREAD_COND_INITIALIZER;130 static StaticLock startupLock; 131 static StaticCondition startupCondition; 132 132 133 133 static WebThreadContext *webThreadContext; … … 682 682 CFRunLoopAddSource(webThreadRunLoop, WebThreadReleaseSource, kCFRunLoopDefaultMode); 683 683 684 int result = pthread_mutex_lock(&startupLock); 685 ASSERT_WITH_MESSAGE(result == 0, "startup lock failed with code:%d", result); 686 687 result = pthread_cond_signal(&startupCondition); 688 ASSERT_WITH_MESSAGE(result == 0, "startup signal failed with code:%d", result); 689 690 result = pthread_mutex_unlock(&startupLock); 691 ASSERT_WITH_MESSAGE(result == 0, "startup unlock failed with code:%d", result); 684 { 685 LockHolder locker(startupLock); 686 startupCondition.notifyOne(); 687 } 692 688 693 689 while (1) … … 759 755 760 756 // Wait for the web thread to startup completely before we continue. 761 int result = pthread_mutex_lock(&startupLock); 762 ASSERT_WITH_MESSAGE(result == 0, "startup lock failed with code:%d", result); 763 764 // Propagate the mainThread's fenv to workers & the web thread. 765 FloatingPointEnvironment::singleton().saveMainThreadEnvironment(); 766 767 pthread_create(&webThread, &tattr, RunWebThread, NULL); 768 pthread_attr_destroy(&tattr); 769 770 result = pthread_cond_wait(&startupCondition, &startupLock); 771 ASSERT_WITH_MESSAGE(result == 0, "startup wait failed with code:%d", result); 772 773 result = pthread_mutex_unlock(&startupLock); 774 ASSERT_WITH_MESSAGE(result == 0, "startup unlock failed with code:%d", result); 757 { 758 LockHolder locker(startupLock); 759 760 // Propagate the mainThread's fenv to workers & the web thread. 761 FloatingPointEnvironment::singleton().saveMainThreadEnvironment(); 762 763 pthread_create(&webThread, &tattr, RunWebThread, NULL); 764 pthread_attr_destroy(&tattr); 765 766 startupCondition.wait(startupLock); 767 } 775 768 776 769 initializeApplicationUIThreadIdentifier();
Note: See TracChangeset
for help on using the changeset viewer.