Changeset 247020 in webkit
- Timestamp:
- Jul 1, 2019 2:11:29 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r247018 r247020 1 2019-07-01 Alex Christensen <achristensen@webkit.org> 2 3 Add main thread assertions in sendWithAsyncReply code 4 https://bugs.webkit.org/show_bug.cgi?id=199324 5 6 Reviewed by Sam Weinig. 7 8 sendWithAsyncReply can only be used on the main thread because 9 the CompletionHandler will be called on the main thread, and if it's 10 called from a background thread, then HashMap corruption will likely happen. 11 Add assertions to alert developers that they should only call sendWithAsyncReply 12 from the main thread. 13 14 This is responding to good feedback from r237294 15 16 * Platform/IPC/Connection.cpp: 17 (IPC::asyncReplyHandlerMap): 18 (IPC::nextAsyncReplyHandlerID): 19 (IPC::addAsyncReplyHandler): 20 (IPC::clearAsyncReplyHandlers): 21 (IPC::CompletionHandler<void): 22 1 23 2019-07-01 Eric Carlson <eric.carlson@apple.com> 2 24 -
trunk/Source/WebKit/Platform/IPC/Connection.cpp
r245767 r247020 240 240 static HashMap<uintptr_t, HashMap<uint64_t, CompletionHandler<void(Decoder*)>>>& asyncReplyHandlerMap() 241 241 { 242 ASSERT(RunLoop::isMain()); 242 243 static NeverDestroyed<HashMap<uintptr_t, HashMap<uint64_t, CompletionHandler<void(Decoder*)>>>> map; 243 244 return map.get(); … … 1128 1129 uint64_t nextAsyncReplyHandlerID() 1129 1130 { 1131 ASSERT(RunLoop::isMain()); 1130 1132 static uint64_t identifier { 0 }; 1131 1133 return ++identifier; … … 1134 1136 void addAsyncReplyHandler(Connection& connection, uint64_t identifier, CompletionHandler<void(Decoder*)>&& completionHandler) 1135 1137 { 1138 ASSERT(RunLoop::isMain()); 1136 1139 auto result = asyncReplyHandlerMap().ensure(reinterpret_cast<uintptr_t>(&connection), [] { 1137 1140 return HashMap<uint64_t, CompletionHandler<void(Decoder*)>>(); … … 1142 1145 void clearAsyncReplyHandlers(const Connection& connection) 1143 1146 { 1147 ASSERT(RunLoop::isMain()); 1144 1148 auto map = asyncReplyHandlerMap().take(reinterpret_cast<uintptr_t>(&connection)); 1145 1149 for (auto& handler : map.values()) { … … 1151 1155 CompletionHandler<void(Decoder*)> takeAsyncReplyHandler(Connection& connection, uint64_t identifier) 1152 1156 { 1157 ASSERT(RunLoop::isMain()); 1153 1158 auto iterator = asyncReplyHandlerMap().find(reinterpret_cast<uintptr_t>(&connection)); 1154 1159 if (iterator != asyncReplyHandlerMap().end()) {
Note: See TracChangeset
for help on using the changeset viewer.