Title: [233784] trunk/Source
- Revision
- 233784
- Author
- cdu...@apple.com
- Date
- 2018-07-12 15:24:34 -0700 (Thu, 12 Jul 2018)
Log Message
Make sure WebProcess::ensureNetworkProcessConnection() is always called on the main thread
https://bugs.webkit.org/show_bug.cgi?id=187607
Reviewed by Alex Christensen.
Add release assertion to make sure that ensureNetworkProcessConnection() is always called on the main
thread. Calling it on a background thread would not be safe. It would not be safe because:
1. We check if we have a network process connection and then create one if we don't without any locking.
2. It is not safe to construct or use a NetworkProcessConnection object from a non-main thread
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::ensureNetworkProcessConnection):
Modified Paths
Diff
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (233783 => 233784)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2018-07-12 22:21:39 UTC (rev 233783)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2018-07-12 22:24:34 UTC (rev 233784)
@@ -1458,6 +1458,7 @@
inline void InspectorInstrumentation::frontendCreated()
{
+ ASSERT(isMainThread());
s_frontendCounter++;
if (s_frontendCounter == 1)
@@ -1466,6 +1467,7 @@
inline void InspectorInstrumentation::frontendDeleted()
{
+ ASSERT(isMainThread());
s_frontendCounter--;
if (!s_frontendCounter)
Modified: trunk/Source/WebCore/inspector/WorkerInspectorController.cpp (233783 => 233784)
--- trunk/Source/WebCore/inspector/WorkerInspectorController.cpp 2018-07-12 22:21:39 UTC (rev 233783)
+++ trunk/Source/WebCore/inspector/WorkerInspectorController.cpp 2018-07-12 22:24:34 UTC (rev 233784)
@@ -110,7 +110,9 @@
createLazyAgents();
- InspectorInstrumentation::frontendCreated();
+ callOnMainThread([] {
+ InspectorInstrumentation::frontendCreated();
+ });
m_executionStopwatch->reset();
m_executionStopwatch->start();
@@ -127,7 +129,9 @@
ASSERT(m_forwardingChannel);
- InspectorInstrumentation::frontendDeleted();
+ callOnMainThread([] {
+ InspectorInstrumentation::frontendDeleted();
+ });
m_agents.willDestroyFrontendAndBackend(reason);
m_frontendRouter->disconnectFrontend(m_forwardingChannel.get());
Modified: trunk/Source/WebKit/ChangeLog (233783 => 233784)
--- trunk/Source/WebKit/ChangeLog 2018-07-12 22:21:39 UTC (rev 233783)
+++ trunk/Source/WebKit/ChangeLog 2018-07-12 22:24:34 UTC (rev 233784)
@@ -1,5 +1,20 @@
2018-07-12 Chris Dumez <cdu...@apple.com>
+ Make sure WebProcess::ensureNetworkProcessConnection() is always called on the main thread
+ https://bugs.webkit.org/show_bug.cgi?id=187607
+
+ Reviewed by Alex Christensen.
+
+ Add release assertion to make sure that ensureNetworkProcessConnection() is always called on the main
+ thread. Calling it on a background thread would not be safe. It would not be safe because:
+ 1. We check if we have a network process connection and then create one if we don't without any locking.
+ 2. It is not safe to construct or use a NetworkProcessConnection object from a non-main thread
+
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::ensureNetworkProcessConnection):
+
+2018-07-12 Chris Dumez <cdu...@apple.com>
+
Assert that the IPC::Connection is valid in Connection::dispatchMessage(Decoder&)
https://bugs.webkit.org/show_bug.cgi?id=187617
Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (233783 => 233784)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2018-07-12 22:21:39 UTC (rev 233783)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2018-07-12 22:24:34 UTC (rev 233784)
@@ -1099,6 +1099,8 @@
NetworkProcessConnection& WebProcess::ensureNetworkProcessConnection()
{
+ RELEASE_ASSERT(RunLoop::isMain());
+
// If we've lost our connection to the network process (e.g. it crashed) try to re-establish it.
if (!m_networkProcessConnection) {
IPC::Attachment encodedConnectionIdentifier;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes