Title: [241304] trunk/Source
Revision
241304
Author
[email protected]
Date
2019-02-12 10:45:31 -0800 (Tue, 12 Feb 2019)

Log Message

[WPE][GTK] Unsafe g_unsetenv() use in WebProcessPool::platformInitialize
https://bugs.webkit.org/show_bug.cgi?id=194370

Reviewed by Darin Adler.

Source/_javascript_Core:

Change a couple WTFLogAlways to use g_warning, for good measure. Of course this isn't
necessary, but it will make errors more visible.

* inspector/remote/glib/RemoteInspectorGlib.cpp:
(Inspector::RemoteInspector::start):
(Inspector::dbusConnectionCallAsyncReadyCallback):
* inspector/remote/glib/RemoteInspectorServer.cpp:
(Inspector::RemoteInspectorServer::start):

Source/WebKit:

It is incorrect to use g_unsetenv() here because it is MT-Unsafe. We know that it is
impossible and unreasonable to expect the application has not started other threads at this
point, and threads will be calling getenv(). WebKit itself has probably already started
threads of its own.

Fortunately, the remote inspector in the web process is already prepared to deal with
failure to connect to the inspector server, so we don't need to do anything except stop
messing with the environment.

Note these files are copies of each other. I'll merge them together in a follow-up patch.

* UIProcess/gtk/WebProcessPoolGtk.cpp:
(WebKit::initializeRemoteInspectorServer):
(WebKit::WebProcessPool::platformInitialize):
* UIProcess/wpe/WebProcessPoolWPE.cpp:
(WebKit::initializeRemoteInspectorServer):
(WebKit::WebProcessPool::platformInitialize):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (241303 => 241304)


--- trunk/Source/_javascript_Core/ChangeLog	2019-02-12 18:23:43 UTC (rev 241303)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-02-12 18:45:31 UTC (rev 241304)
@@ -1,3 +1,19 @@
+2019-02-12  Michael Catanzaro  <[email protected]>
+
+        [WPE][GTK] Unsafe g_unsetenv() use in WebProcessPool::platformInitialize
+        https://bugs.webkit.org/show_bug.cgi?id=194370
+
+        Reviewed by Darin Adler.
+
+        Change a couple WTFLogAlways to use g_warning, for good measure. Of course this isn't
+        necessary, but it will make errors more visible.
+
+        * inspector/remote/glib/RemoteInspectorGlib.cpp:
+        (Inspector::RemoteInspector::start):
+        (Inspector::dbusConnectionCallAsyncReadyCallback):
+        * inspector/remote/glib/RemoteInspectorServer.cpp:
+        (Inspector::RemoteInspectorServer::start):
+
 2019-02-12  Andy Estes  <[email protected]>
 
         [iOSMac] Enable Parental Controls Content Filtering

Modified: trunk/Source/_javascript_Core/inspector/remote/glib/RemoteInspectorGlib.cpp (241303 => 241304)


--- trunk/Source/_javascript_Core/inspector/remote/glib/RemoteInspectorGlib.cpp	2019-02-12 18:23:43 UTC (rev 241303)
+++ trunk/Source/_javascript_Core/inspector/remote/glib/RemoteInspectorGlib.cpp	2019-02-12 18:45:31 UTC (rev 241304)
@@ -79,7 +79,7 @@
             if (GRefPtr<GDBusConnection> connection = adoptGRef(g_dbus_connection_new_for_address_finish(result, &error.outPtr())))
                 inspector->setupConnection(WTFMove(connection));
             else if (!g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED))
-                WTFLogAlways("RemoteInspector failed to connect to inspector server at: %s: %s", g_getenv("WEBKIT_INSPECTOR_SERVER"), error->message);
+                g_warning("RemoteInspector failed to connect to inspector server at: %s: %s", g_getenv("WEBKIT_INSPECTOR_SERVER"), error->message);
     }, this);
 }
 
@@ -178,7 +178,7 @@
     GUniqueOutPtr<GError> error;
     GRefPtr<GVariant> resultVariant = adoptGRef(g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error.outPtr()));
     if (!resultVariant && !g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED))
-        WTFLogAlways("RemoteInspector failed to send DBus message: %s", error->message);
+        g_warning("RemoteInspector failed to send DBus message: %s", error->message);
 }
 
 TargetListing RemoteInspector::listingForInspectionTarget(const RemoteInspectionTarget& target) const

Modified: trunk/Source/_javascript_Core/inspector/remote/glib/RemoteInspectorServer.cpp (241303 => 241304)


--- trunk/Source/_javascript_Core/inspector/remote/glib/RemoteInspectorServer.cpp	2019-02-12 18:23:43 UTC (rev 241303)
+++ trunk/Source/_javascript_Core/inspector/remote/glib/RemoteInspectorServer.cpp	2019-02-12 18:45:31 UTC (rev 241304)
@@ -197,7 +197,7 @@
     m_dbusServer = adoptGRef(g_dbus_server_new_sync(dbusAddress.get(), G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS, uid.get(), nullptr, m_cancellable.get(), &error.outPtr()));
     if (!m_dbusServer) {
         if (!g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED))
-            WTFLogAlways("Failed to start remote inspector server on %s: %s\n", dbusAddress.get(), error->message);
+            g_warning("Failed to start remote inspector server on %s: %s\n", dbusAddress.get(), error->message);
         return false;
     }
 

Modified: trunk/Source/WebKit/ChangeLog (241303 => 241304)


--- trunk/Source/WebKit/ChangeLog	2019-02-12 18:23:43 UTC (rev 241303)
+++ trunk/Source/WebKit/ChangeLog	2019-02-12 18:45:31 UTC (rev 241304)
@@ -1,3 +1,28 @@
+2019-02-12  Michael Catanzaro  <[email protected]>
+
+        [WPE][GTK] Unsafe g_unsetenv() use in WebProcessPool::platformInitialize
+        https://bugs.webkit.org/show_bug.cgi?id=194370
+
+        Reviewed by Darin Adler.
+
+        It is incorrect to use g_unsetenv() here because it is MT-Unsafe. We know that it is
+        impossible and unreasonable to expect the application has not started other threads at this
+        point, and threads will be calling getenv(). WebKit itself has probably already started
+        threads of its own.
+
+        Fortunately, the remote inspector in the web process is already prepared to deal with
+        failure to connect to the inspector server, so we don't need to do anything except stop
+        messing with the environment.
+
+        Note these files are copies of each other. I'll merge them together in a follow-up patch.
+
+        * UIProcess/gtk/WebProcessPoolGtk.cpp:
+        (WebKit::initializeRemoteInspectorServer):
+        (WebKit::WebProcessPool::platformInitialize):
+        * UIProcess/wpe/WebProcessPoolWPE.cpp:
+        (WebKit::initializeRemoteInspectorServer):
+        (WebKit::WebProcessPool::platformInitialize):
+
 2019-02-08  Beth Dakin  <[email protected]>
 
         Ensure old binaries have old snapshotting behaviors

Modified: trunk/Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp (241303 => 241304)


--- trunk/Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp	2019-02-12 18:23:43 UTC (rev 241303)
+++ trunk/Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp	2019-02-12 18:45:31 UTC (rev 241304)
@@ -45,26 +45,26 @@
 namespace WebKit {
 
 #if ENABLE(REMOTE_INSPECTOR)
-static bool initializeRemoteInspectorServer(const char* address)
+static void initializeRemoteInspectorServer(const char* address)
 {
     if (Inspector::RemoteInspectorServer::singleton().isRunning())
-        return true;
+        return;
 
     if (!address[0])
-        return false;
+        return;
 
     GUniquePtr<char> inspectorAddress(g_strdup(address));
     char* portPtr = g_strrstr(inspectorAddress.get(), ":");
     if (!portPtr)
-        return false;
+        return;
 
     *portPtr = '\0';
     portPtr++;
     guint64 port = g_ascii_strtoull(portPtr, nullptr, 10);
     if (!port)
-        return false;
+        return;
 
-    return Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port);
+    Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port);
 }
 #endif
 
@@ -77,10 +77,8 @@
 void WebProcessPool::platformInitialize()
 {
 #if ENABLE(REMOTE_INSPECTOR)
-    if (const char* address = g_getenv("WEBKIT_INSPECTOR_SERVER")) {
-        if (!initializeRemoteInspectorServer(address))
-            g_unsetenv("WEBKIT_INSPECTOR_SERVER");
-    }
+    if (const char* address = g_getenv("WEBKIT_INSPECTOR_SERVER"))
+        initializeRemoteInspectorServer(address);
 #endif
 
     if (!memoryPressureMonitorDisabled())

Modified: trunk/Source/WebKit/UIProcess/wpe/WebProcessPoolWPE.cpp (241303 => 241304)


--- trunk/Source/WebKit/UIProcess/wpe/WebProcessPoolWPE.cpp	2019-02-12 18:23:43 UTC (rev 241303)
+++ trunk/Source/WebKit/UIProcess/wpe/WebProcessPoolWPE.cpp	2019-02-12 18:45:31 UTC (rev 241304)
@@ -51,26 +51,26 @@
 namespace WebKit {
 
 #if ENABLE(REMOTE_INSPECTOR)
-static bool initializeRemoteInspectorServer(const char* address)
+static void initializeRemoteInspectorServer(const char* address)
 {
     if (Inspector::RemoteInspectorServer::singleton().isRunning())
-        return true;
+        return;
 
     if (!address[0])
-        return false;
+        return;
 
     GUniquePtr<char> inspectorAddress(g_strdup(address));
     char* portPtr = g_strrstr(inspectorAddress.get(), ":");
     if (!portPtr)
-        return false;
+        return;
 
     *portPtr = '\0';
     portPtr++;
     guint64 port = g_ascii_strtoull(portPtr, nullptr, 10);
     if (!port)
-        return false;
+        return;
 
-    return Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port);
+    Inspector::RemoteInspectorServer::singleton().start(inspectorAddress.get(), port);
 }
 #endif
 
@@ -77,10 +77,8 @@
 void WebProcessPool::platformInitialize()
 {
 #if ENABLE(REMOTE_INSPECTOR)
-    if (const char* address = g_getenv("WEBKIT_INSPECTOR_SERVER")) {
-        if (!initializeRemoteInspectorServer(address))
-            g_unsetenv("WEBKIT_INSPECTOR_SERVER");
-    }
+    if (const char* address = g_getenv("WEBKIT_INSPECTOR_SERVER"))
+        initializeRemoteInspectorServer(address);
 #endif
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to