Title: [285222] trunk
- Revision
- 285222
- Author
- [email protected]
- Date
- 2021-11-03 13:12:23 -0700 (Wed, 03 Nov 2021)
Log Message
_pasteboardWithName should be thread-safe
https://bugs.webkit.org/show_bug.cgi?id=232670
Reviewed by Tim Horton.
Source/WTF:
wtf/Atomics.h uses WTF_MAKE_STRUCT_FAST_ALLOCATED which is declared in
wtf/FastMalloc.h but was failing to include it. This was leading to a
build error when I tried including wtf/Lock.h in WKTR.
* wtf/Atomics.h:
Tools:
_pasteboardWithName should be thread-safe, to match [NSPasteboard _pasteboardWithName].
This was leading to flaky crashes in _pasteboardWithName getting called off the main
thread from ShareKit code.
* DumpRenderTree/mac/DumpRenderTreePasteboard.mm:
(+[DumpRenderTreePasteboard _pasteboardWithName:]):
(+[DumpRenderTreePasteboard releaseLocalPasteboards]):
* WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm:
(+[WebKitTestRunnerPasteboard _pasteboardWithName:]):
(+[WebKitTestRunnerPasteboard releaseLocalPasteboards]):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (285221 => 285222)
--- trunk/Source/WTF/ChangeLog 2021-11-03 20:11:28 UTC (rev 285221)
+++ trunk/Source/WTF/ChangeLog 2021-11-03 20:12:23 UTC (rev 285222)
@@ -1,3 +1,16 @@
+2021-11-03 Chris Dumez <[email protected]>
+
+ _pasteboardWithName should be thread-safe
+ https://bugs.webkit.org/show_bug.cgi?id=232670
+
+ Reviewed by Tim Horton.
+
+ wtf/Atomics.h uses WTF_MAKE_STRUCT_FAST_ALLOCATED which is declared in
+ wtf/FastMalloc.h but was failing to include it. This was leading to a
+ build error when I tried including wtf/Lock.h in WKTR.
+
+ * wtf/Atomics.h:
+
2021-11-02 Brady Eidson <[email protected]>
Notifications on iOS enabled at compile-time, disabled at runtime
Modified: trunk/Source/WTF/wtf/Atomics.h (285221 => 285222)
--- trunk/Source/WTF/wtf/Atomics.h 2021-11-03 20:11:28 UTC (rev 285221)
+++ trunk/Source/WTF/wtf/Atomics.h 2021-11-03 20:12:23 UTC (rev 285222)
@@ -26,6 +26,7 @@
#pragma once
#include <atomic>
+#include <wtf/FastMalloc.h>
#include <wtf/StdLibExtras.h>
#if OS(WINDOWS)
Modified: trunk/Tools/ChangeLog (285221 => 285222)
--- trunk/Tools/ChangeLog 2021-11-03 20:11:28 UTC (rev 285221)
+++ trunk/Tools/ChangeLog 2021-11-03 20:12:23 UTC (rev 285222)
@@ -1,3 +1,21 @@
+2021-11-03 Chris Dumez <[email protected]>
+
+ _pasteboardWithName should be thread-safe
+ https://bugs.webkit.org/show_bug.cgi?id=232670
+
+ Reviewed by Tim Horton.
+
+ _pasteboardWithName should be thread-safe, to match [NSPasteboard _pasteboardWithName].
+ This was leading to flaky crashes in _pasteboardWithName getting called off the main
+ thread from ShareKit code.
+
+ * DumpRenderTree/mac/DumpRenderTreePasteboard.mm:
+ (+[DumpRenderTreePasteboard _pasteboardWithName:]):
+ (+[DumpRenderTreePasteboard releaseLocalPasteboards]):
+ * WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm:
+ (+[WebKitTestRunnerPasteboard _pasteboardWithName:]):
+ (+[WebKitTestRunnerPasteboard releaseLocalPasteboards]):
+
2021-11-03 Ryan Haddad <[email protected]>
[EWS] Add more bots to iOS layout and API test queues
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm (285221 => 285222)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm 2021-11-03 20:11:28 UTC (rev 285221)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTreePasteboard.mm 2021-11-03 20:12:23 UTC (rev 285222)
@@ -39,6 +39,7 @@
#import <wtf/Assertions.h>
#import <wtf/HashMap.h>
#import <wtf/ListHashSet.h>
+#import <wtf/Lock.h>
#import <wtf/RetainPtr.h>
@interface LocalPasteboard : NSPasteboard {
@@ -55,7 +56,8 @@
-(id)initWithName:(NSString *)name;
@end
-static RetainPtr<NSMutableDictionary> localPasteboards;
+static Lock localPasteboardsLock;
+static RetainPtr<NSMutableDictionary> localPasteboards WTF_GUARDED_BY_LOCK(localPasteboardsLock);
@implementation DumpRenderTreePasteboard
@@ -62,9 +64,10 @@
// Return a local pasteboard so we don't disturb the real pasteboards when running tests.
+ (NSPasteboard *)_pasteboardWithName:(NSString *)name
{
- static int number = 0;
+ Locker locker { localPasteboardsLock };
+ static uint64_t number WTF_GUARDED_BY_LOCK(localPasteboardsLock) = 0;
if (!name)
- name = [NSString stringWithFormat:@"LocalPasteboard%d", ++number];
+ name = [NSString stringWithFormat:@"LocalPasteboard%llu", ++number];
if (!localPasteboards)
localPasteboards = adoptNS([[NSMutableDictionary alloc] init]);
if (LocalPasteboard *pasteboard = [localPasteboards objectForKey:name])
@@ -76,6 +79,7 @@
+ (void)releaseLocalPasteboards
{
+ Locker locker { localPasteboardsLock };
localPasteboards = nil;
}
Modified: trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm (285221 => 285222)
--- trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm 2021-11-03 20:11:28 UTC (rev 285221)
+++ trunk/Tools/WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm 2021-11-03 20:12:23 UTC (rev 285222)
@@ -30,6 +30,7 @@
#import "NSPasteboardAdditions.h"
#import <objc/runtime.h>
+#import <wtf/Lock.h>
#import <wtf/RetainPtr.h>
@interface LocalPasteboard : NSPasteboard
@@ -45,7 +46,8 @@
-(id)initWithName:(NSString *)name;
@end
-static RetainPtr<NSMutableDictionary> localPasteboards;
+static Lock localPasteboardsLock;
+static RetainPtr<NSMutableDictionary> localPasteboards WTF_GUARDED_BY_LOCK(localPasteboardsLock);
@implementation WebKitTestRunnerPasteboard
@@ -52,9 +54,10 @@
// Return a local pasteboard so we don't disturb the real pasteboards when running tests.
+ (NSPasteboard *)_pasteboardWithName:(NSString *)name
{
- static int number = 0;
+ Locker locker { localPasteboardsLock };
+ static uint64_t number WTF_GUARDED_BY_LOCK(localPasteboardsLock) = 0;
if (!name)
- name = [NSString stringWithFormat:@"LocalPasteboard%d", ++number];
+ name = [NSString stringWithFormat:@"LocalPasteboard%llu", ++number];
if (!localPasteboards)
localPasteboards = adoptNS([[NSMutableDictionary alloc] init]);
if (LocalPasteboard *pasteboard = [localPasteboards objectForKey:name])
@@ -72,6 +75,7 @@
+ (void)releaseLocalPasteboards
{
+ Locker locker { localPasteboardsLock };
localPasteboards = nil;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes