hang in g_spawn_sync and select()

Bug #690239 reported by Didier Roche-Tolomelli
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Compiz Core
Fix Released
Undecided
Sam Spilsbury
glib2.0 (Ubuntu)
Invalid
High
Unassigned
Natty
Won't Fix
High
Unassigned

Bug Description

This happens particularly on session start with compiz launched by gnome-session.

this happens with 1:0.9.2.1+glibmainloop3-0ubuntu1 which get the backend data at the very beginning of its initializaion (-0ubuntu2 delay that a little bit and is working fine).

A more complete backtrace in a different case seems to be related at https://bugzilla.redhat.com/show_bug.cgi?format=multiple&id=654027

(gdb) attach 4088
Attaching to process 4088
[…]
0x0028d416 in __kernel_vsyscall ()
(gdb) bt
#0 0x0028d416 in __kernel_vsyscall ()
#1 0x0040235d in select () from /lib/libc.so.6
#2 0x0019a40b in g_spawn_sync (working_directory=0x0, argv=0x9b46530, envp=0x0, flags=G_SPAWN_SEARCH_PATH, child_setup=0, user_data=0x0,
    standard_output=0xbfab84ac, standard_error=0xbfab84a8, exit_status=0xbfab84a4, error=0xbfab851c) at /build/buildd/glib2.0-2.27.4/glib/gspawn.c:321
#3 0x0019a9ac in g_spawn_command_line_sync (
    command_line=0x9b46438 "dbus-launch --autolaunch=403b6ccfaa8567027cff37a700000008 --binary-syntax --close-stderr", standard_output=0xbfab84ac,
    standard_error=0xbfab84a8, exit_status=0xbfab84a4, error=0xbfab851c) at /build/buildd/glib2.0-2.27.4/glib/gspawn.c:706
#4 0x0100dfba in get_session_address_dbus_launch (error=0xbfab851c) at /build/buildd/glib2.0-2.27.4/gio/gdbusaddress.c:1039
#5 0x0100fb41 in get_session_address_platform_specific (bus_type=G_BUS_TYPE_SESSION, cancellable=0x0, error=0xbfab8638)
    at /build/buildd/glib2.0-2.27.4/gio/gdbusaddress.c:1136
#6 g_dbus_address_get_for_bus_sync (bus_type=G_BUS_TYPE_SESSION, cancellable=0x0, error=0xbfab8638) at /build/buildd/glib2.0-2.27.4/gio/gdbusaddress.c:1219
#7 0x01019db9 in get_uninitialized_connection (bus_type=G_BUS_TYPE_SESSION, cancellable=0x0, error=0xbfab8638)
    at /build/buildd/glib2.0-2.27.4/gio/gdbusconnection.c:6209
#8 0x01021d0d in g_bus_get_sync (bus_type=G_BUS_TYPE_SESSION, cancellable=0x0, error=0xbfab8638) at /build/buildd/glib2.0-2.27.4/gio/gdbusconnection.c:6268
#9 0x004a50b7 in ?? () from /usr/lib/libgconf-2.so.4
#10 0x004a5374 in gconf_activate_server () from /usr/lib/libgconf-2.so.4
#11 0x004afb8c in ?? () from /usr/lib/libgconf-2.so.4
#12 0x004b0571 in ?? () from /usr/lib/libgconf-2.so.4
#13 0x004b07d6 in ?? () from /usr/lib/libgconf-2.so.4
#14 0x004b1127 in gconf_engine_notify_add () from /usr/lib/libgconf-2.so.4
#15 0x004b8902 in gconf_client_add_dir () from /usr/lib/libgconf-2.so.4
#16 0x00823138 in ?? () from /usr/lib/compizconfig/backends/libgconf.so
#17 0x0082514a in ?? () from /usr/lib/compizconfig/backends/libgconf.so
#18 0x0030fb7c in ccsSetBackend () from /usr/lib/libcompizconfig.so.0
#19 0x003117d0 in ?? () from /usr/lib/libcompizconfig.so.0
#20 0x00311970 in ccsEmptyContextNew () from /usr/lib/libcompizconfig.so.0
#21 0x00311a85 in ccsContextNew () from /usr/lib/libcompizconfig.so.0
#22 0x002b0902 in CcpScreen::CcpScreen(CompScreen*) () from /usr/lib/compiz/libccp.so
#23 0x002b14c4 in CompPlugin::VTableForScreen<CcpScreen>::initScreen(CompScreen*) () from /usr/lib/compiz/libccp.so
#24 0x08093dcc in CompPlugin::screenInitPlugins(CompScreen*) ()
#25 0x08074ebe in CompScreen::init(char const*) ()
#26 0x08065d69 in CompManager::init() ()
#27 0x08065fb5 in main ()
(gdb) quit

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: libglib2.0-0 2.27.4-0ubuntu1
ProcVersionSignature: Ubuntu 2.6.37-8.21-generic 2.6.37-rc4
Uname: Linux 2.6.37-8-generic i686
NonfreeKernelModules: nvidia
Architecture: i386
Date: Tue Dec 14 17:33:18 2010
InstallationMedia: Ubuntu 10.10 "Maverick Meerkat" - Alpha i386 (20100918)
ProcEnviron:
 PATH=(custom, user)
 LANG=fr_FR.utf8
 SHELL=/bin/bash
SourcePackage: glib2.0

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :
Revision history for this message
David Barth (dbarth) wrote :

Ryan: we need your help for fixing this issue rapidly, it's making the life of compiz really miserable now (and Sam's as well). Thanks

Changed in glib2.0 (Ubuntu):
assignee: nobody → Ryan Lortie (desrt)
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Alright, after some discussions with Ryan, I had a look into this again, and I have now fixed the problem in compiz. Some notes about this:

 * DBUS_SESSION_BUS_ADDRESS in the program's env isn't mandatory, since dbus can scrape that information from the root window property if it has X11 support
 * DBUS_SESSION_BUS_ADDRESS *won't* appear in the program env if it was launched from a VT or SSH or something
 * Compiz issues an UngrabServer request right after doing XQueryTree, and then initializes plugin screens right afterwards (before initializing every window).
 * UngrabServer isn't a synchronous operation, so there's a race for the X Server to process that in time
 * On CcpScreen's ctor, it will initialize libcompizconfig which loads backends (gconf)
 * GConf initializes and starts DBus to get a connection with the gconf server
 * GDbus sees that DBUS_SESSION_BUS_ADDRESS isn't set and calls dbus-launch --autolaunch to try and get the bus address
 * dbus-launch --autolaunch calls get_bus_address_platform_specific (X11 backend) which calls XOpenDisplay () and XGetWindowProperty () to try and get the session bus address from the window prop
 * The UngrabServer request hasn't been processed yet, so XOpenDisplay instantly fails
 * GDbus is using g_spawn_sync incorrectly and doesn't restore normal child handling, so when the child process dbus-launch fails to return an address (very rare case), it just blocks forever until glib times out the request. This is what causes the apparent hang, then crash 2 minutes later

All of the items above the last one have been fixed compiz-side so this is no longer an issue (though it does pose an interesting problem that trying to get the session bus address while a server grab is active will fail - that is probably a bad thing and should be resolved, maybe a temp socket file should be created in the user's homedir?). Anyways, I believe that while the last item is essentially a corner-case, it still prints an interesting debug message if the command failed to get the bus address and should be fixed.

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks Sam. So I'm untargetting this for natty, to get it off the release blocker list.

Changed in glib2.0 (Ubuntu Natty):
status: Confirmed → Won't Fix
Changed in glib2.0 (Ubuntu):
status: Confirmed → Triaged
Changed in compiz-core:
assignee: nobody → Sam Spilsbury (smspillaz)
milestone: none → 0.9.6
status: New → Fix Committed
Changed in compiz-core:
status: Fix Committed → Fix Released
Changed in glib2.0 (Ubuntu):
status: Triaged → Invalid
assignee: Ryan Lortie (desrt) → nobody
Changed in glib2.0 (Ubuntu Natty):
assignee: Ryan Lortie (desrt) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.