WebKit Bugzilla
Attachment 373255 Details for
Bug 199324
: Add main thread assertions in sendWithAsyncReply code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199324-20190701134839.patch (text/plain), 3.24 KB, created by
Alex Christensen
on 2019-07-01 13:48:40 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2019-07-01 13:48:40 PDT
Size:
3.24 KB
patch
obsolete
>Subversion Revision: 246896 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index dcb3e109101ae7c82471a0356db0837bcc825f13..09e7d6688e348e88b9108e6b2e5373efc0b9f190 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,25 @@ >+2019-07-01 Alex Christensen <achristensen@webkit.org> >+ >+ Add main thread assertions in sendWithAsyncReply code >+ https://bugs.webkit.org/show_bug.cgi?id=199324 >+ >+ Reviewed by Sam Weinig. >+ >+ sendWithAsyncReply can only be used on the main thread because >+ the CompletionHandler will be called on the main thread, and if it's >+ called from a background thread, then HashMap corruption will likely happen. >+ Add assertions to alert developers that they should only call sendWithAsyncReply >+ from the main thread. >+ >+ This is responding to good feedback from r237294 >+ >+ * Platform/IPC/Connection.cpp: >+ (IPC::asyncReplyHandlerMap): >+ (IPC::nextAsyncReplyHandlerID): >+ (IPC::addAsyncReplyHandler): >+ (IPC::clearAsyncReplyHandlers): >+ (IPC::CompletionHandler<void): >+ > 2019-06-27 Carlos Garcia Campos <cgarcia@igalia.com> > > WebSockets: avoid data copies when queuing tasks in WebSocketChannel >diff --git a/Source/WebKit/Platform/IPC/Connection.cpp b/Source/WebKit/Platform/IPC/Connection.cpp >index 361f8619d23c848075bc1074fd67f4ae08cb99b5..921a62228bd80ddf57f0d7976842259f013c7ea6 100644 >--- a/Source/WebKit/Platform/IPC/Connection.cpp >+++ b/Source/WebKit/Platform/IPC/Connection.cpp >@@ -239,6 +239,7 @@ static HashMap<IPC::Connection::UniqueID, Connection*>& allConnections() > > static HashMap<uintptr_t, HashMap<uint64_t, CompletionHandler<void(Decoder*)>>>& asyncReplyHandlerMap() > { >+ ASSERT(RunLoop::isMain()); > static NeverDestroyed<HashMap<uintptr_t, HashMap<uint64_t, CompletionHandler<void(Decoder*)>>>> map; > return map.get(); > } >@@ -1127,12 +1128,14 @@ void Connection::dispatchIncomingMessages() > > uint64_t nextAsyncReplyHandlerID() > { >+ ASSERT(RunLoop::isMain()); > static uint64_t identifier { 0 }; > return ++identifier; > } > > void addAsyncReplyHandler(Connection& connection, uint64_t identifier, CompletionHandler<void(Decoder*)>&& completionHandler) > { >+ ASSERT(RunLoop::isMain()); > auto result = asyncReplyHandlerMap().ensure(reinterpret_cast<uintptr_t>(&connection), [] { > return HashMap<uint64_t, CompletionHandler<void(Decoder*)>>(); > }).iterator->value.add(identifier, WTFMove(completionHandler)); >@@ -1141,6 +1144,7 @@ void addAsyncReplyHandler(Connection& connection, uint64_t identifier, Completio > > void clearAsyncReplyHandlers(const Connection& connection) > { >+ ASSERT(RunLoop::isMain()); > auto map = asyncReplyHandlerMap().take(reinterpret_cast<uintptr_t>(&connection)); > for (auto& handler : map.values()) { > if (handler) >@@ -1150,6 +1154,7 @@ void clearAsyncReplyHandlers(const Connection& connection) > > CompletionHandler<void(Decoder*)> takeAsyncReplyHandler(Connection& connection, uint64_t identifier) > { >+ ASSERT(RunLoop::isMain()); > auto iterator = asyncReplyHandlerMap().find(reinterpret_cast<uintptr_t>(&connection)); > if (iterator != asyncReplyHandlerMap().end()) { > if (!iterator->value.isValidKey(identifier)) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199324
:
373124
| 373255