Modified: trunk/Source/WebKit2/ChangeLog (205182 => 205183)
--- trunk/Source/WebKit2/ChangeLog 2016-08-30 16:34:01 UTC (rev 205182)
+++ trunk/Source/WebKit2/ChangeLog 2016-08-30 16:35:48 UTC (rev 205183)
@@ -1,3 +1,28 @@
+2016-08-29 Anders Carlsson <[email protected]>
+
+ Stop using m_client to indicate whether an IPC::Connection is valid
+ https://bugs.webkit.org/show_bug.cgi?id=161362
+
+ Reviewed by Andreas Kling.
+
+ Instead, add an std::atomic<bool> so we can reliably check the state from other threads.
+
+ * Platform/IPC/Connection.cpp:
+ (IPC::Connection::Connection):
+ (IPC::Connection::invalidate):
+ (IPC::Connection::connectionDidClose):
+ (IPC::Connection::dispatchSyncMessage):
+ (IPC::Connection::dispatchDidReceiveInvalidMessage):
+ (IPC::Connection::dispatchMessage):
+ * Platform/IPC/Connection.h:
+ (IPC::Connection::client):
+ (IPC::Connection::isValid):
+ (IPC::Connection::waitForAndDispatchImmediately):
+ * UIProcess/WebGeolocationManagerProxy.cpp:
+ (WebKit::WebGeolocationManagerProxy::startUpdating):
+ (WebKit::WebGeolocationManagerProxy::stopUpdating):
+ (WebKit::WebGeolocationManagerProxy::setEnableHighAccuracy):
+
2016-08-30 Carlos Garcia Campos <[email protected]>
REGRESSION(r194846): [GTK] UI process crash visiting sites protected with HTTP auth when using GTK+ < 3.14
Modified: trunk/Source/WebKit2/Platform/IPC/Connection.cpp (205182 => 205183)
--- trunk/Source/WebKit2/Platform/IPC/Connection.cpp 2016-08-30 16:34:01 UTC (rev 205182)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.cpp 2016-08-30 16:35:48 UTC (rev 205183)
@@ -214,7 +214,7 @@
}
Connection::Connection(Identifier identifier, bool isServer, Client& client)
- : m_client(&client)
+ : m_client(client)
, m_isServer(isServer)
, m_syncRequestID(0)
, m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(false)
@@ -315,12 +315,14 @@
void Connection::invalidate()
{
+ ASSERT(RunLoop::isMain());
+
if (!isValid()) {
// Someone already called invalidate().
return;
}
- m_client = nullptr;
+ m_isValid = false;
m_connectionQueue->dispatch([protectedThis = makeRef(*this)]() mutable {
protectedThis->platformInvalidate();
@@ -722,17 +724,15 @@
RunLoop::main().dispatch([protectedThis = makeRef(*this)]() mutable {
// If the connection has been explicitly invalidated before dispatchConnectionDidClose was called,
- // then the client will be null here.
- if (!protectedThis->m_client)
+ // then the the connection will be invalid here.
+ if (!protectedThis->isValid())
return;
- // Because we define a connection as being "valid" based on wheter it has a null client, we null out
- // the client before calling didClose here. Otherwise, sendSync will try to send a message to the connection and
- // will then wait indefinitely for a reply.
- Client* client = protectedThis->m_client;
- protectedThis->m_client = nullptr;
+ // Set m_isValid to false before calling didClose, otherwise, sendSync will try to send a message
+ // to the connection and will then wait indefinitely for a reply.
+ protectedThis->m_isValid = false;
- client->didClose(protectedThis.get());
+ protectedThis->m_client.didClose(protectedThis.get());
});
}
@@ -786,7 +786,7 @@
SyncMessageState::singleton().dispatchMessages(nullptr);
} else {
// Hand off both the decoder and encoder to the client.
- m_client->didReceiveSyncMessage(*this, decoder, replyEncoder);
+ m_client.didReceiveSyncMessage(*this, decoder, replyEncoder);
}
// FIXME: If the message was invalid, we should send back a SyncMessageError.
@@ -800,10 +800,10 @@
{
ASSERT(RunLoop::isMain());
- if (!m_client)
+ if (!isValid())
return;
- m_client->didReceiveInvalidMessage(*this, StringReference(messageReceiverNameString.data(), messageReceiverNameString.length()), StringReference(messageNameString.data(), messageNameString.length()));
+ m_client.didReceiveInvalidMessage(*this, StringReference(messageReceiverNameString.data(), messageReceiverNameString.length()), StringReference(messageNameString.data(), messageNameString.length()));
}
void Connection::didFailToSendSyncMessage()
@@ -828,17 +828,17 @@
void Connection::dispatchMessage(Decoder& decoder)
{
- m_client->didReceiveMessage(*this, decoder);
+ m_client.didReceiveMessage(*this, decoder);
}
void Connection::dispatchMessage(std::unique_ptr<Decoder> message)
{
- if (!m_client)
+ if (!isValid())
return;
if (message->shouldUseFullySynchronousModeForTesting()) {
if (!m_fullySynchronousModeIsAllowedForTesting) {
- m_client->didReceiveInvalidMessage(*this, message->messageReceiverName(), message->messageName());
+ m_client.didReceiveInvalidMessage(*this, message->messageReceiverName(), message->messageName());
return;
}
m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting++;
@@ -868,8 +868,8 @@
if (message->shouldUseFullySynchronousModeForTesting())
m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting--;
- if (m_didReceiveInvalidMessage && m_client)
- m_client->didReceiveInvalidMessage(*this, message->messageReceiverName(), message->messageName());
+ if (m_didReceiveInvalidMessage && isValid())
+ m_client.didReceiveInvalidMessage(*this, message->messageReceiverName(), message->messageName());
m_didReceiveInvalidMessage = oldDidReceiveInvalidMessage;
}
Modified: trunk/Source/WebKit2/Platform/IPC/Connection.h (205182 => 205183)
--- trunk/Source/WebKit2/Platform/IPC/Connection.h 2016-08-30 16:34:01 UTC (rev 205182)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.h 2016-08-30 16:35:48 UTC (rev 205183)
@@ -137,7 +137,7 @@
static Ref<Connection> createClientConnection(Identifier, Client&);
~Connection();
- Client* client() const { return m_client; }
+ Client& client() const { return m_client; }
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000
void setShouldCloseConnectionOnMachExceptions();
@@ -186,7 +186,7 @@
void terminateSoon(double intervalInSeconds);
#endif
- bool isValid() const { return m_client; }
+ bool isValid() const { return m_isValid; }
#if HAVE(QOS_CLASSES)
void setShouldBoostMainThreadOnSyncMessage(bool b) { m_shouldBoostMainThreadOnSyncMessage = b; }
@@ -237,8 +237,9 @@
std::chrono::milliseconds timeoutRespectingIgnoreTimeoutsForTesting(std::chrono::milliseconds) const;
- Client* m_client;
+ Client& m_client;
bool m_isServer;
+ std::atomic<bool> m_isValid { true };
std::atomic<uint64_t> m_syncRequestID;
bool m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage;
@@ -365,7 +366,7 @@
return false;
ASSERT(decoder->destinationID() == destinationID);
- m_client->didReceiveMessage(*this, *decoder);
+ m_client.didReceiveMessage(*this, *decoder);
return true;
}
Modified: trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp (205182 => 205183)
--- trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp 2016-08-30 16:34:01 UTC (rev 205182)
+++ trunk/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp 2016-08-30 16:35:48 UTC (rev 205183)
@@ -106,7 +106,7 @@
void WebGeolocationManagerProxy::startUpdating(IPC::Connection& connection)
{
bool wasUpdating = isUpdating();
- m_updateRequesters.add(connection.client());
+ m_updateRequesters.add(&connection.client());
if (!wasUpdating) {
m_provider.setEnableHighAccuracy(this, isHighAccuracyEnabled());
m_provider.startUpdating(this);
@@ -115,7 +115,7 @@
void WebGeolocationManagerProxy::stopUpdating(IPC::Connection& connection)
{
- removeRequester(connection.client());
+ removeRequester(&connection.client());
}
void WebGeolocationManagerProxy::removeRequester(const IPC::Connection::Client* client)
@@ -140,9 +140,9 @@
bool highAccuracyWasEnabled = isHighAccuracyEnabled();
if (enabled)
- m_highAccuracyRequesters.add(connection.client());
+ m_highAccuracyRequesters.add(&connection.client());
else
- m_highAccuracyRequesters.remove(connection.client());
+ m_highAccuracyRequesters.remove(&connection.client());
bool highAccuracyShouldBeEnabled = isHighAccuracyEnabled();
if (isUpdating() && highAccuracyWasEnabled != highAccuracyShouldBeEnabled)