Changeset 232886 in webkit
- Timestamp:
- Jun 15, 2018 12:28:18 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r232884 r232886 1 2018-06-15 Brady Eidson <beidson@apple.com> 2 3 Crash in both StorageProcess and UIProcess when using custom WKWebsiteDataStores for data management. 4 <rdar://problem/41019893> and https://bugs.webkit.org/show_bug.cgi?id=186682 5 6 Reviewed by Chris Dumez. 7 8 * UIProcess/Storage/StorageProcessProxy.cpp: 9 (WebKit::StorageProcessProxy::didClose): Protect this and the process pool as the cleanup that follows 10 might cause either to get destroyed. 11 12 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 13 (WebKit::WebsiteDataStore::fetchDataAndApply): Protect the operating WebsiteDataStore while async operations 14 are in flight. Otherwise if the data store is destroyed, the SessionIDs for those operations will get 15 destroyed before they complete. 16 (WebKit::WebsiteDataStore::removeData): Ditto. 17 1 18 2018-06-15 Per Arne Vollan <pvollan@apple.com> 2 19 -
trunk/Source/WebKit/UIProcess/Storage/StorageProcessProxy.cpp
r231931 r232886 136 136 void StorageProcessProxy::didClose(IPC::Connection&) 137 137 { 138 auto protectedProcessPool = makeRef(m_processPool); 139 138 140 // The storage process must have crashed or exited, so send any pending sync replies we might have. 139 141 while (!m_pendingConnectionReplies.isEmpty()) { … … 149 151 } 150 152 151 for (const auto& callback : m_pendingFetchWebsiteDataCallbacks.values()) 152 callback(WebsiteData()); 153 m_pendingFetchWebsiteDataCallbacks.clear(); 154 155 for (const auto& callback : m_pendingDeleteWebsiteDataCallbacks.values()) 156 callback(); 157 m_pendingDeleteWebsiteDataCallbacks.clear(); 158 159 for (const auto& callback : m_pendingDeleteWebsiteDataForOriginsCallbacks.values()) 160 callback(); 161 m_pendingDeleteWebsiteDataForOriginsCallbacks.clear(); 153 while (!m_pendingFetchWebsiteDataCallbacks.isEmpty()) 154 m_pendingFetchWebsiteDataCallbacks.take(m_pendingFetchWebsiteDataCallbacks.begin()->key)(WebsiteData { }); 155 156 while (!m_pendingDeleteWebsiteDataCallbacks.isEmpty()) 157 m_pendingDeleteWebsiteDataCallbacks.take(m_pendingDeleteWebsiteDataCallbacks.begin()->key)(); 158 159 while (!m_pendingDeleteWebsiteDataForOriginsCallbacks.isEmpty()) 160 m_pendingDeleteWebsiteDataForOriginsCallbacks.take(m_pendingDeleteWebsiteDataForOriginsCallbacks.begin()->key)(); 162 161 163 162 // Tell ProcessPool to forget about this storage process. This may cause us to be deleted. -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r232863 r232886 237 237 { 238 238 struct CallbackAggregator final : ThreadSafeRefCounted<CallbackAggregator> { 239 explicit CallbackAggregator(OptionSet<WebsiteDataFetchOption> fetchOptions, RefPtr<WorkQueue>&& queue, Function<void(Vector<WebsiteDataRecord>)>&& apply )239 explicit CallbackAggregator(OptionSet<WebsiteDataFetchOption> fetchOptions, RefPtr<WorkQueue>&& queue, Function<void(Vector<WebsiteDataRecord>)>&& apply, WebsiteDataStore& dataStore) 240 240 : fetchOptions(fetchOptions) 241 241 , queue(WTFMove(queue)) 242 242 , apply(WTFMove(apply)) 243 , protectedDataStore(dataStore) 243 244 { 244 245 } … … 345 346 346 347 HashMap<String, WebsiteDataRecord> m_websiteDataRecords; 348 Ref<WebsiteDataStore> protectedDataStore; 347 349 }; 348 350 349 RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(fetchOptions, WTFMove(queue), WTFMove(apply) ));351 RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(fetchOptions, WTFMove(queue), WTFMove(apply), *this)); 350 352 351 353 #if ENABLE(VIDEO) … … 649 651 { 650 652 struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> { 651 explicit CallbackAggregator( Function<void()>&& completionHandler)653 explicit CallbackAggregator(WebsiteDataStore& dataStore, Function<void()>&& completionHandler) 652 654 : completionHandler(WTFMove(completionHandler)) 655 , protectedDataStore(dataStore) 653 656 { 654 657 } … … 675 678 unsigned pendingCallbacks = 0; 676 679 Function<void()> completionHandler; 680 Ref<WebsiteDataStore> protectedDataStore; 677 681 }; 678 682 679 RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator( WTFMove(completionHandler)));683 RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(*this, WTFMove(completionHandler))); 680 684 681 685 #if ENABLE(VIDEO) … … 907 911 908 912 struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> { 909 explicit CallbackAggregator( Function<void()>&& completionHandler)913 explicit CallbackAggregator(WebsiteDataStore& dataStore, Function<void()>&& completionHandler) 910 914 : completionHandler(WTFMove(completionHandler)) 915 , protectedDataStore(dataStore) 911 916 { 912 917 } … … 933 938 unsigned pendingCallbacks = 0; 934 939 Function<void()> completionHandler; 940 Ref<WebsiteDataStore> protectedDataStore; 935 941 }; 936 942 937 RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator( WTFMove(completionHandler)));943 RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(*this, WTFMove(completionHandler))); 938 944 939 945 if (dataTypes.contains(WebsiteDataType::DiskCache)) { -
trunk/Tools/ChangeLog
r232885 r232886 1 2018-06-15 Brady Eidson <beidson@apple.com> 2 3 Crash in both StorageProcess and UIProcess when using custom WKWebsiteDataStores for data management. 4 <rdar://problem/41019893> and https://bugs.webkit.org/show_bug.cgi?id=186682 5 6 Reviewed by Chris Dumez. 7 8 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 9 * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm: 10 (TEST): 11 1 12 2018-06-15 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 13 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r232664 r232886 180 180 51393E221523952D005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */; }; 181 181 5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */; }; 182 51460E1220D421F2005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51460E0F20D4216E005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3 */; }; 183 51460E1320D421F2005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3-shm in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51460E1020D4216E005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3-shm */; }; 184 51460E1420D421F2005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3-wal in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51460E1120D4216E005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3-wal */; }; 182 185 514958BE1F7427AC00E87BAD /* WKWebViewAutofillTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */; }; 183 186 515BE16F1D428BB100DD7C68 /* StoreBlobToBeDeleted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 515BE16E1D4288FF00DD7C68 /* StoreBlobToBeDeleted.html */; }; … … 885 888 dstSubfolderSpec = 7; 886 889 files = ( 890 51460E1220D421F2005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3 in Copy Resources */, 891 51460E1320D421F2005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3-shm in Copy Resources */, 892 51460E1420D421F2005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3-wal in Copy Resources */, 887 893 1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */, 888 894 379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */, … … 1392 1398 5142B2701517C88B00C32B19 /* ContextMenuCanCopyURL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuCanCopyURL.mm; sourceTree = "<group>"; }; 1393 1399 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContextMenuCanCopyURL.html; sourceTree = "<group>"; }; 1400 51460E0F20D4216E005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SimpleServiceWorkerRegistrations-2.sqlite3"; sourceTree = "<group>"; }; 1401 51460E1020D4216E005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3-shm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SimpleServiceWorkerRegistrations-2.sqlite3-shm"; sourceTree = "<group>"; }; 1402 51460E1120D4216E005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3-wal */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SimpleServiceWorkerRegistrations-2.sqlite3-wal"; sourceTree = "<group>"; }; 1394 1403 514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewAutofillTests.mm; sourceTree = "<group>"; }; 1395 1404 515BE16E1D4288FF00DD7C68 /* StoreBlobToBeDeleted.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = StoreBlobToBeDeleted.html; sourceTree = "<group>"; }; … … 2470 2479 isa = PBXGroup; 2471 2480 children = ( 2481 51460E0F20D4216E005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3 */, 2482 51460E1020D4216E005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3-shm */, 2483 51460E1120D4216E005345F2 /* SimpleServiceWorkerRegistrations-2.sqlite3-wal */, 2472 2484 C25CCA0C1E5140E50026CB8A /* AllAhem.svg */, 2473 2485 F4A9202E1FEE34C800F59590 /* apple-data-url.html */, -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm
r231603 r232886 226 226 } 227 227 228 TEST(WebKit, CustomDataStorePathsVersusCompletionHandlers) 229 { 230 // Copy the baked database files to the database directory 231 NSURL *url1 = [[NSBundle mainBundle] URLForResource:@"SimpleServiceWorkerRegistrations-2" withExtension:@"sqlite3" subdirectory:@"TestWebKitAPI.resources"]; 232 NSURL *url2 = [[NSBundle mainBundle] URLForResource:@"SimpleServiceWorkerRegistrations-2" withExtension:@"sqlite3-shm" subdirectory:@"TestWebKitAPI.resources"]; 233 NSURL *url3 = [[NSBundle mainBundle] URLForResource:@"SimpleServiceWorkerRegistrations-2" withExtension:@"sqlite3-wal" subdirectory:@"TestWebKitAPI.resources"]; 234 235 NSURL *swPath = [NSURL fileURLWithPath:[@"~/Library/Caches/TestWebKitAPI/WebKit/ServiceWorkers/" stringByExpandingTildeInPath]]; 236 [[NSFileManager defaultManager] removeItemAtURL:swPath error:nil]; 237 EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:swPath.path]); 238 239 [[NSFileManager defaultManager] createDirectoryAtURL:swPath withIntermediateDirectories:YES attributes:nil error:nil]; 240 [[NSFileManager defaultManager] copyItemAtURL:url1 toURL:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-2.sqlite3"] error:nil]; 241 [[NSFileManager defaultManager] copyItemAtURL:url2 toURL:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-2.sqlite3-shm"] error:nil]; 242 [[NSFileManager defaultManager] copyItemAtURL:url3 toURL:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-2.sqlite3-wal"] error:nil]; 243 244 auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]); 245 websiteDataStoreConfiguration.get()._serviceWorkerRegistrationDirectory = swPath; 246 auto dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]); 247 248 // Fetch SW records 249 auto websiteDataTypes = adoptNS([[NSSet alloc] initWithArray:@[WKWebsiteDataTypeServiceWorkerRegistrations]]); 250 static bool readyToContinue; 251 [dataStore fetchDataRecordsOfTypes:websiteDataTypes.get() completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) { 252 EXPECT_EQ((int)dataRecords.count, 1); 253 readyToContinue = true; 254 }]; 255 TestWebKitAPI::Util::run(&readyToContinue); 256 readyToContinue = false; 257 258 // Fetch records again, this time releasing our reference to the data store while the request is in flight. 259 // Without a bug fix, this would crash the StorageProcess and the UI process wouldn't get the info back. 260 [dataStore fetchDataRecordsOfTypes:websiteDataTypes.get() completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) { 261 EXPECT_EQ((int)dataRecords.count, 1); 262 readyToContinue = true; 263 }]; 264 dataStore = nil; 265 TestWebKitAPI::Util::run(&readyToContinue); 266 readyToContinue = false; 267 268 // Delete all SW records, releasing our reference to the data store while the request is in flight. 269 // Same as above - We used to crash the storage process and the records weren't actually deleted. 270 dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]); 271 [dataStore removeDataOfTypes:websiteDataTypes.get() modifiedSince:[NSDate distantPast] completionHandler:^() { 272 readyToContinue = true; 273 }]; 274 dataStore = nil; 275 TestWebKitAPI::Util::run(&readyToContinue); 276 readyToContinue = false; 277 278 // The StorageProcess should not have crashed, the records should have been deleted, and the callback should have been made. 279 // Now refetch the records to verify they are gone. 280 dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]); 281 [dataStore fetchDataRecordsOfTypes:websiteDataTypes.get() completionHandler:^(NSArray<WKWebsiteDataRecord *> *dataRecords) { 282 EXPECT_EQ((int)dataRecords.count, 0); 283 readyToContinue = true; 284 }]; 285 TestWebKitAPI::Util::run(&readyToContinue); 286 } 287 228 288 TEST(WebKit, WebsiteDataStoreEphemeral) 229 289 {
Note: See TracChangeset
for help on using the changeset viewer.