[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 13:36:46 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6deaf89e39de0beb73ad58cad4b0f95ded735d44
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 21 15:39:09 2010 +0000

    Zombie WebProcesses are left around
    https://bugs.webkit.org/show_bug.cgi?id=46148
    <rdar://problem/8455898>
    
    Reviewed by Dan Bernstein.
    
    * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
    (WebKit::setupTerminationNotificationHandler):
    Register a dispatch handler that calls waitpid when the child process exits. This prevents zombies from
    staying around after the child process has quit.
    
    (WebKit::ProcessLauncher::launchProcess):
    Pass POSIX_SPAWN_START_SUSPENDED to posix_spawn to avoid race conditions when setting up the termination
    notification handler. When the handler is set up we send the SIGCONT signal to the child process.
    
    * mac/MainMac.cpp:
    (main):
    Loop through all file descriptors except for stdin, stdout and stderr and close them.
    
    * WebKit2.xcodeproj/project.pbxproj:
    Soft-link the Web process with WebKit2. We do this so we can ensure that we won't accidentally close any
    file descriptors opened by initialization code that would have been called before main().
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67954 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index fa29800..a4c2350 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,28 @@
+2010-09-20  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Zombie WebProcesses are left around
+        https://bugs.webkit.org/show_bug.cgi?id=46148
+        <rdar://problem/8455898>
+
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::setupTerminationNotificationHandler):
+        Register a dispatch handler that calls waitpid when the child process exits. This prevents zombies from
+        staying around after the child process has quit.
+
+        (WebKit::ProcessLauncher::launchProcess):
+        Pass POSIX_SPAWN_START_SUSPENDED to posix_spawn to avoid race conditions when setting up the termination
+        notification handler. When the handler is set up we send the SIGCONT signal to the child process.
+        
+        * mac/MainMac.cpp:
+        (main):
+        Loop through all file descriptors except for stdin, stdout and stderr and close them.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Soft-link the Web process with WebKit2. We do this so we can ensure that we won't accidentally close any
+        file descriptors opened by initialization code that would have been called before main().
+
 2010-09-21  Andras Becsi  <abecsi at inf.u-szeged.hu>
 
         Reviewed by Csaba Osztrogonác.
diff --git a/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
index 4326543..dd464ec 100644
--- a/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
+++ b/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
@@ -73,6 +73,22 @@ static const char* processName()
 }
 #endif
 
+static void setUpTerminationNotificationHandler(pid_t pid)
+{
+#if HAVE(DISPATCH_H)
+    dispatch_source_t processDiedSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, pid, DISPATCH_PROC_EXIT, dispatch_get_current_queue());
+    dispatch_source_set_event_handler(processDiedSource, ^{
+        int status;
+        waitpid(dispatch_source_get_handle(processDiedSource), &status, 0);
+        dispatch_source_cancel(processDiedSource);
+    });
+    dispatch_source_set_cancel_handler(processDiedSource, ^{
+        dispatch_release(processDiedSource);
+    });
+    dispatch_resume(processDiedSource);
+#endif
+}
+
 void ProcessLauncher::launchProcess()
 {
     // Create the listening port.
@@ -93,12 +109,13 @@ void ProcessLauncher::launchProcess()
 
     // Register ourselves.
     kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.data()), listeningPort, 0);
-    if (kr)
-        NSLog(@"bootstrap_register2 result: %x", kr);
+    ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
 
     posix_spawnattr_t attr;
     posix_spawnattr_init(&attr);
 
+    // FIXME: Should we restore signals here?
+
 #if CPU(X86)
     // Ensure that the child process runs as the same architecture as the parent process. 
     cpu_type_t cpuTypes[] = { CPU_TYPE_X86 };    
@@ -106,14 +123,19 @@ void ProcessLauncher::launchProcess()
     posix_spawnattr_setbinpref_np(&attr, 1, cpuTypes, &outCount);
 #endif
 
+    // Start suspended so we can set up the termination notification handler.
+    posix_spawnattr_setflags(&attr, POSIX_SPAWN_START_SUSPENDED);
+
     pid_t processIdentifier;
     int result = posix_spawn(&processIdentifier, path, 0, &attr, (char *const*)args, *_NSGetEnviron());
+    ASSERT_UNUSED(result, !result);
 
     posix_spawnattr_destroy(&attr);
 
-    if (result)
-        NSLog(@"posix_spawn result: %d", result);
-
+    // Set up the termination notification handler and then ask the child process to continue.
+    setUpTerminationNotificationHandler(processIdentifier);
+    kill(processIdentifier, SIGCONT);
+    
     // We've finished launching the process, message back to the main run loop.
     RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, processIdentifier, listeningPort));
 }
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 8923231..d2c8839 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -36,7 +36,6 @@
 		1A0F29CC120B37160053D1B9 /* VisitedLinkTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0F29CA120B37160053D1B9 /* VisitedLinkTable.h */; };
 		1A0F29E3120B44420053D1B9 /* VisitedLinkProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0F29E1120B44420053D1B9 /* VisitedLinkProvider.cpp */; };
 		1A0F29E4120B44420053D1B9 /* VisitedLinkProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0F29E2120B44420053D1B9 /* VisitedLinkProvider.h */; };
-		1A10475A110A5AD500A43ECD /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C7DE100E846E0078DEBC /* JavaScriptCore.framework */; };
 		1A1C4EC810D06099005E67E7 /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C79A100E7FC50078DEBC /* WebCore.framework */; };
 		1A1C649B11F4174200553C19 /* WebContextMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A1C648611F415B700553C19 /* WebContextMac.mm */; };
 		1A2161B011F37664008AD0F5 /* NPRuntimeObjectMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2161AE11F37664008AD0F5 /* NPRuntimeObjectMap.h */; };
@@ -90,14 +89,12 @@
 		1AEFCCBD11D02C5E008219D3 /* PluginInfoStoreMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEFCCBC11D02C5E008219D3 /* PluginInfoStoreMac.mm */; };
 		1AEFD27911D16C81008219D3 /* ArgumentCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEFD27811D16C81008219D3 /* ArgumentCoder.h */; };
 		1AEFD2F711D1807B008219D3 /* ArgumentCoders.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEFD2F611D1807B008219D3 /* ArgumentCoders.h */; };
-		1AF3060A111B599E00F96436 /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* WebKit2.framework */; };
 		514AF6C81209EE7300A26C97 /* WKData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514AF6C61209EE7300A26C97 /* WKData.cpp */; };
 		514AF6C91209EE7300A26C97 /* WKData.h in Headers */ = {isa = PBXBuildFile; fileRef = 514AF6C71209EE7300A26C97 /* WKData.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		51578B831209ECEF00A37C4A /* WebData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51578B821209ECEF00A37C4A /* WebData.h */; };
 		516A4A59120A1AB500C05B7F /* WKError.h in Headers */ = {isa = PBXBuildFile; fileRef = 516A4A57120A1AB500C05B7F /* WKError.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		516A4A5A120A1AB500C05B7F /* WKError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516A4A58120A1AB500C05B7F /* WKError.cpp */; };
 		516A4A5D120A2CCD00C05B7F /* WebError.h in Headers */ = {isa = PBXBuildFile; fileRef = 516A4A5B120A2CCD00C05B7F /* WebError.h */; };
-		5DAD729C116FF86200EE5396 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
 		6D8A91A611F0EFD100DD01FE /* com.apple.WebProcess.sb in Resources */ = {isa = PBXBuildFile; fileRef = 6D8A91A511F0EFD100DD01FE /* com.apple.WebProcess.sb */; };
 		762B748D120BC75C00819339 /* WKPreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 762B7484120BBA2D00819339 /* WKPreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		762B74AF120BC94F00819339 /* WKPreferencesPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 762B749D120BC8EA00819339 /* WKPreferencesPrivate.cpp */; };
@@ -763,16 +760,6 @@
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
-		1A50DB1C110A3BDC000D3FE5 /* Frameworks */ = {
-			isa = PBXFrameworksBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				5DAD729C116FF86200EE5396 /* AppKit.framework in Frameworks */,
-				1A10475A110A5AD500A43ECD /* JavaScriptCore.framework in Frameworks */,
-				1AF3060A111B599E00F96436 /* WebKit2.framework in Frameworks */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
 		8DC2EF560486A6940098B216 /* Frameworks */ = {
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
@@ -1684,7 +1671,6 @@
 			buildPhases = (
 				1A50DB1A110A3BDC000D3FE5 /* Resources */,
 				1A50DB1B110A3BDC000D3FE5 /* Sources */,
-				1A50DB1C110A3BDC000D3FE5 /* Frameworks */,
 			);
 			buildRules = (
 			);
diff --git a/WebKit2/mac/MainMac.cpp b/WebKit2/mac/MainMac.cpp
index a1c704e..0f79b61 100644
--- a/WebKit2/mac/MainMac.cpp
+++ b/WebKit2/mac/MainMac.cpp
@@ -23,10 +23,18 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-// The framework entry point.
-extern "C" int WebKitMain(int argc, char **argv);
+#include <WebCore/SoftLinking.h>
+
+SOFT_LINK_FRAMEWORK(WebKit2);
+SOFT_LINK(WebKit2, WebKitMain, int, (int argc, char **argv), (argc, argv));
 
 int main(int argc, char** argv)
 {
+    int numFDs = getdtablesize();
+
+    // Close all file descriptors except stdin, stdout and stderr.
+    for (int fd = 3; fd < numFDs; ++fd)
+        close(fd);
+
     return WebKitMain(argc, argv);
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list