Changeset 248525 in webkit
- Timestamp:
- Aug 11, 2019 7:00:30 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r248494 r248525 1 2019-08-11 Chris Dumez <cdumez@apple.com> 2 3 Add threading assertions to RefCounted 4 https://bugs.webkit.org/show_bug.cgi?id=200507 5 6 Reviewed by Ryosuke Niwa. 7 8 * dfg/DFGPlan.cpp: 9 (JSC::DFG::Plan::Plan): 10 Disable threading assertions for DFG::Plan::m_inlineCallFrames while the JSC team 11 investigates. 12 1 13 2019-08-09 Yusuke Suzuki <ysuzuki@apple.com> 2 14 -
trunk/Source/JavaScriptCore/dfg/DFGPlan.cpp
r248027 r248525 151 151 { 152 152 RELEASE_ASSERT(m_codeBlock->alternative()->jitCode()); 153 m_inlineCallFrames->disableThreadingChecks(); 153 154 } 154 155 -
trunk/Source/WTF/ChangeLog
r248488 r248525 1 2019-08-11 Chris Dumez <cdumez@apple.com> 2 3 Add threading assertions to RefCounted 4 https://bugs.webkit.org/show_bug.cgi?id=200507 5 6 Reviewed by Ryosuke Niwa. 7 8 Add threading assertions to RefCounted to try and catch unsafe concurrent ref'ing / derefing of 9 RefCounted objects from several threads. If you hit these new assertions, it likely means you either 10 need to: 11 1. Have your class subclass ThreadSafeRefCounted instead of RefCounted 12 or 13 2. Make sure your objects always gets ref'd / deref'd from the same thread. 14 15 These assertions already found several thread safety bugs in our code base, which I fixed via 16 dependency bugs. 17 18 These assertions are currently enabled in WebKit (UIProcess, child processes and 19 WebKitLegacy), they do not apply other JavascriptCore API clients. 20 21 * WTF.xcodeproj/project.pbxproj: 22 * wtf/CMakeLists.txt: 23 * wtf/RefCounted.cpp: Added. 24 * wtf/RefCounted.h: 25 (WTF::RefCountedBase::ref const): 26 (WTF::RefCountedBase::disableThreadingChecks): 27 (WTF::RefCountedBase::enableThreadingChecksGlobally): 28 (WTF::RefCountedBase::RefCountedBase): 29 (WTF::RefCountedBase::areThreadingCheckedEnabled const): 30 (WTF::RefCountedBase::derefBase const): 31 * wtf/SizeLimits.cpp: 32 1 33 2019-08-09 Saam Barati <sbarati@apple.com> 2 34 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r248441 r248525 62 62 3337DB9CE743410FAF076E17 /* StackTrace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 313EDEC9778E49C9BEA91CFC /* StackTrace.cpp */; }; 63 63 4427C5AA21F6D6C300A612A4 /* ASCIICType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4427C5A921F6D6C300A612A4 /* ASCIICType.cpp */; }; 64 46BEB6EB22FFE24900269867 /* RefCounted.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46BEB6E922FFDDD500269867 /* RefCounted.cpp */; }; 64 65 50DE35F5215BB01500B979C7 /* ExternalStringImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50DE35F3215BB01500B979C7 /* ExternalStringImpl.cpp */; }; 65 66 515F794E1CFC9F4A00CCED93 /* CrossThreadCopier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515F794B1CFC9F4A00CCED93 /* CrossThreadCopier.cpp */; }; … … 345 346 4427C5A921F6D6C300A612A4 /* ASCIICType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ASCIICType.cpp; sourceTree = "<group>"; }; 346 347 46BA9EAB1F4CD61E009A2BBC /* CompletionHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompletionHandler.h; sourceTree = "<group>"; }; 348 46BEB6E922FFDDD500269867 /* RefCounted.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RefCounted.cpp; sourceTree = "<group>"; }; 347 349 50DE35F3215BB01500B979C7 /* ExternalStringImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExternalStringImpl.cpp; sourceTree = "<group>"; }; 348 350 50DE35F4215BB01500B979C7 /* ExternalStringImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExternalStringImpl.h; sourceTree = "<group>"; }; … … 1108 1110 A8A472FE151A825B004123FF /* RedBlackTree.h */, 1109 1111 26299B6D17A9E5B800ADEBE5 /* Ref.h */, 1112 46BEB6E922FFDDD500269867 /* RefCounted.cpp */, 1110 1113 A8A472FF151A825B004123FF /* RefCounted.h */, 1111 1114 A8A47300151A825B004123FF /* RefCountedArray.h */, … … 1601 1604 A8A47414151A825B004123FF /* RandomNumber.cpp in Sources */, 1602 1605 0FEC3C5E1F368A9700F59B6C /* ReadWriteLock.cpp in Sources */, 1606 46BEB6EB22FFE24900269867 /* RefCounted.cpp in Sources */, 1603 1607 A8A4741A151A825B004123FF /* RefCountedLeakCounter.cpp in Sources */, 1604 1608 E392FA2722E92BFF00ECDC73 /* ResourceUsageCocoa.cpp in Sources */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r247815 r248525 394 394 RandomNumber.cpp 395 395 ReadWriteLock.cpp 396 RefCounted.cpp 396 397 RefCountedLeakCounter.cpp 397 398 RunLoop.cpp -
trunk/Source/WTF/wtf/RefCounted.h
r248488 r248525 23 23 #include <wtf/Assertions.h> 24 24 #include <wtf/FastMalloc.h> 25 #include <wtf/MainThread.h> 25 26 #include <wtf/Noncopyable.h> 26 27 … … 40 41 void ref() const 41 42 { 43 #if !ASSERT_DISABLED 44 if (m_isOwnedByMainThread != isMainThread() && hasOneRef()) 45 m_isOwnedByMainThread = isMainThread(); // Likely ownership transfer. 46 47 // If you hit this assertion, it means that the RefCounted object was ref'd or deref'd 48 // concurrent from several threads, which is not safe. You should either subclass 49 // ThreadSafeRefCounted instead, or make sure to always ref / deref from the same thread. 50 ASSERT_WITH_MESSAGE(!areThreadingCheckedEnabled() || m_isOwnedByMainThread == isMainThread(), "Should not be ref'd / deref'd concurrently from several threads"); 51 #endif 52 42 53 #if CHECK_REF_COUNTED_LIFECYCLE 43 54 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); … … 69 80 } 70 81 82 // Please only call this method if you really know that what you're doing is safe (e.g. 83 // locking at call sites). 84 void disableThreadingChecks() 85 { 86 #if !ASSERT_DISABLED 87 m_areThreadingChecksEnabled = false; 88 #endif 89 } 90 91 static void enableThreadingChecksGlobally() 92 { 93 #if !ASSERT_DISABLED 94 areThreadingChecksEnabledGlobally = true; 95 #endif 96 } 97 71 98 protected: 72 99 RefCountedBase() 73 100 : m_refCount(1) 101 #if !ASSERT_DISABLED 102 , m_isOwnedByMainThread(isMainThread()) 103 #endif 74 104 #if CHECK_REF_COUNTED_LIFECYCLE 75 105 , m_deletionHasBegun(false) … … 79 109 } 80 110 111 #if !ASSERT_DISABLED 112 bool areThreadingCheckedEnabled() const 113 { 114 return areThreadingChecksEnabledGlobally && m_areThreadingChecksEnabled; 115 } 116 #endif 117 81 118 ~RefCountedBase() 82 119 { … … 90 127 bool derefBase() const 91 128 { 129 #if !ASSERT_DISABLED 130 if (m_isOwnedByMainThread != isMainThread() && hasOneRef()) 131 m_isOwnedByMainThread = isMainThread(); // Likely ownership transfer. 132 133 // If you hit this assertion, it means that the RefCounted object was ref'd or deref'd 134 // concurrent from several threads, which is not safe. You should either subclass 135 // ThreadSafeRefCounted instead, or make sure to always ref / deref from the same thread. 136 ASSERT_WITH_MESSAGE(!areThreadingCheckedEnabled() || m_isOwnedByMainThread == isMainThread(), "Should not be ref'd / deref'd concurrently from several threads"); 137 #endif 138 92 139 #if CHECK_REF_COUNTED_LIFECYCLE 93 140 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); … … 121 168 122 169 mutable unsigned m_refCount; 170 #if !ASSERT_DISABLED 171 mutable bool m_isOwnedByMainThread; 172 bool m_areThreadingChecksEnabled { true }; 173 WTF_EXPORT_PRIVATE static bool areThreadingChecksEnabledGlobally; 174 #endif 123 175 #if CHECK_REF_COUNTED_LIFECYCLE 124 176 mutable bool m_deletionHasBegun; -
trunk/Source/WTF/wtf/SizeLimits.cpp
r230130 r248525 46 46 bool b; 47 47 bool c; 48 bool d; 49 bool e; 48 50 // The debug version may get bigger. 49 51 }; -
trunk/Source/WebKit/ChangeLog
r248522 r248525 1 2019-08-11 Chris Dumez <cdumez@apple.com> 2 3 Add threading assertions to RefCounted 4 https://bugs.webkit.org/show_bug.cgi?id=200507 5 6 Reviewed by Ryosuke Niwa. 7 8 Enable new RefCounted threading assertions for WebKit2 9 (UIProcess + auxiliary processes). 10 11 * Shared/AuxiliaryProcess.cpp: 12 (WebKit::AuxiliaryProcess::initialize): 13 * Shared/Cocoa/WebKit2InitializeCocoa.mm: 14 (WebKit::runInitializationCode): 15 * Shared/WebKit2Initialize.cpp: 16 (WebKit::InitializeWebKit2): 17 1 18 2019-08-11 Wenson Hsieh <wenson_hsieh@apple.com> 2 19 -
trunk/Source/WebKit/Shared/AuxiliaryProcess.cpp
r243528 r248525 61 61 void AuxiliaryProcess::initialize(const AuxiliaryProcessInitializationParameters& parameters) 62 62 { 63 WTF::RefCountedBase::enableThreadingChecksGlobally(); 64 63 65 RELEASE_ASSERT_WITH_MESSAGE(parameters.processIdentifier, "Unable to initialize child process without a WebCore process identifier"); 64 66 Process::setIdentifier(*parameters.processIdentifier); -
trunk/Source/WebKit/Shared/Cocoa/WebKit2InitializeCocoa.mm
r237266 r248525 32 32 #import <mutex> 33 33 #import <wtf/MainThread.h> 34 #import <wtf/RefCounted.h> 34 35 #import <wtf/RunLoop.h> 35 36 … … 50 51 JSC::initializeThreading(); 51 52 RunLoop::initializeMainRunLoop(); 53 54 WTF::RefCountedBase::enableThreadingChecksGlobally(); 52 55 53 56 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED -
trunk/Source/WebKit/Shared/WebKit2Initialize.cpp
r228218 r248525 31 31 #include <WebCore/LogInitialization.h> 32 32 #include <wtf/MainThread.h> 33 #include <wtf/RefCounted.h> 33 34 #include <wtf/RunLoop.h> 34 35 … … 42 43 RunLoop::initializeMainRunLoop(); 43 44 45 WTF::RefCountedBase::enableThreadingChecksGlobally(); 46 44 47 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 45 48 WebCore::initializeLogChannelsIfNecessary(); -
trunk/Source/WebKitLegacy/mac/ChangeLog
r248498 r248525 1 2019-08-11 Chris Dumez <cdumez@apple.com> 2 3 Add threading assertions to RefCounted 4 https://bugs.webkit.org/show_bug.cgi?id=200507 5 6 Reviewed by Ryosuke Niwa. 7 8 * WebView/WebView.mm: 9 (+[WebView initialize]): 10 Enable new RefCounted threading assertions for WebKitLegacy. 11 1 12 2019-08-10 Tim Horton <timothy_horton@apple.com> 2 13 -
trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
r248498 r248525 5417 5417 #endif 5418 5418 5419 WTF::RefCountedBase::enableThreadingChecksGlobally(); 5420 5419 5421 WTF::setProcessPrivileges(allPrivileges()); 5420 5422 WebCore::NetworkStorageSession::permitProcessToUseCookieAPI(true);
Note: See TracChangeset
for help on using the changeset viewer.