Bug 21347

Summary: signal race in _dbus_get_autolaunch_address()
Product: dbus Reporter: Kurt Miller <kurt>
Component: coreAssignee: Havoc Pennington <hp>
Status: RESOLVED FIXED QA Contact: John (J5) Palmieri <johnp>
Severity: major    
Priority: medium CC: walters
Version: 1.2.x   
Hardware: All   
OS: OpenBSD   
Whiteboard:
i915 platform: i915 features:
Attachments: Block SIGCHLD in _dbus_get_autolaunch_address() to stop race

Description Kurt Miller 2009-04-22 16:49:07 UTC
Created attachment 25049 [details] [review]
Block SIGCHLD in _dbus_get_autolaunch_address() to stop race

Application utilizing _dbus_get_autolaunch_address() which also have a signal handler for SIGCHLD that does the waitpid() on the child have a race. If the signal is delivered and handled by the application before _dbus_get_autolaunch_address() calls waitpid() then the call to waitpid() will fail and causing the "dbus: Failed to get connection: Failed to execute dbus-launch to autolaunch D-Bus session" error.

For example pidgin has a signal handler for SIGCHLD that calls waitpid() and cleans up the zombie. When pigdin has the dbus example plugin enabled and is executed directly, it calls _dbus_get_autolaunch_address(). The race occurs and many times it looses and displays a dialog with the above error message.

See: http://bugs.gentoo.org/223925

Attached is a patch to fix the race.
Comment 1 Colin Walters 2009-07-10 16:20:16 UTC
Uggh.  Ok.  I added a comment to your patch and cleaned it up to conform to coding conventions, applied now.  Thanks.

commit 644fc38b249b490981becda4b2de5261865bba23
Author: Kurt Miller <kurt@intricatesoftware.com>
Date:   Fri Jul 10 19:14:10 2009 -0400

    Bug 21347 - Don't fail autolaunching if process has SIGCHLD handler
    
    If other code in the process set a global SIGCHLD handler, it
    will make autolaunching fail spuriously due to waitpid() failing.
    
    This fix will temporarily block SIGCHLD delivery.
    
    Signed-off-by: Colin Walters <walters@verbum.org>

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.