[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#413273: ksplash: hangs on startup due to race condition



Package: ksplash
Version: 4:3.5.5a.dfsg.1-6
Severity: important
Tags: patch

ksplash backgrounds itself early on so the startup process in 
/usr/bin/startkde can continue. ksplash is doing this too early, and it 
leads to a race condition where if ksplash loses the race, the programs 
started by startkde will do their work, send a signal to ksplash, and 
the signal will fail to be used due to ksplash not being ready for it 
yet. After losing the race ksplash will hang

Originaly reported, patched, and verifyed here:
https://bugs.launchpad.net/ubuntu/+source/kdebase/+bug/46682
There is also an anti-patch that makes it easier to reproduce the bug.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.10-5-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages ksplash depends on:
ii  kdebase-data           4:3.5.5a.dfsg.1-6 shared data files for the KDE base
ii  kdelibs4c2a            4:3.5.5a.dfsg.1-6 core libraries and binaries for al
ii  libart-2.0-2           2.3.17-1          Library of functions for 2D graphi
ii  libaudio2              1.7-9             The Network Audio System (NAS). (s
ii  libc6                  2.3.6-15          GNU C Library: Shared libraries
ii  libfontconfig1         2.4.2-1.2         generic font configuration library
ii  libfreetype6           2.2.1-2           FreeType 2 font engine, shared lib
ii  libgcc1                1:4.1.1-21        GCC support library
ii  libice6                1:1.0.0-3         X11 Inter-Client Exchange library
ii  libidn11               0.6.3-1           GNU libidn library, implementation
ii  libjpeg62              6b-13             The Independent JPEG Group's JPEG 
ii  libpng12-0             1.2.15~beta5-1    PNG library - runtime
ii  libqt3-mt              3:3.3.7-3         Qt GUI Library (Threaded runtime v
ii  libsm6                 1:1.0.0-4         X11 Session Management library
ii  libstdc++6             4.1.1-21          The GNU Standard C++ Library v3
ii  libx11-6               2:1.0.0-7         X11 client-side library
ii  libxcursor1            1.1.5.2-5         X cursor management library
ii  libxext6               1:1.0.0-4         X11 miscellaneous extension librar
ii  libxft2                2.1.8.2-8         FreeType-based font drawing librar
ii  libxi6                 1:1.0.0-5         X11 Input extension library
ii  libxinerama1           1:1.0.1-4         X11 Xinerama extension library
ii  libxrandr2             2:1.1.0.2-4       X11 RandR extension library
ii  libxrender1            1:0.9.0.2-4       X Rendering Extension client libra
ii  libxt6                 1:1.0.0-5         X11 toolkit intrinsics library
ii  zlib1g                 1:1.2.3-12        compression library - runtime

ksplash recommends no packages.

-- no debconf information
--- startkde.orig	2007-03-03 13:17:24.000000000 -0600
+++ startkde	2007-03-03 14:47:33.041487432 -0600
@@ -304,11 +304,13 @@
      ;; # nothing
   Simple)
      if test "$kpersonalizerrc_general_firstlogin" = "true"; then
-         ksplashsimple 
+# increase the chance that ksplashsimple loses the race to illustrate bug
+         nice -n 19 ksplashsimple 
      fi # otherwise started earlier
      ;;
   *)
-     ksplash --nodcop
+# increase the chance that ksplashsimple loses the race to illustrate bug
+     nice -n 19 ksplash --nodcop
      ;;
 esac
 
@@ -346,7 +348,8 @@
   kwrapper kdesktop_lock --forcelock &
   # Give it some time for starting up. This is somewhat unclean; some
   # notification would be better.
-  sleep 1
+  # commented out to increase the chance the ksplash loses the race
+#  sleep 1
 fi
 
 # finally, give the session control to the session manager
--- kdebase-3.5.5a.dfsg.1/ksplashml/main.cpp	2007-03-03 14:50:34.963831032 -0600
+++ kdebase-3.5.5a.dfsg.1.orig/ksplashml/main.cpp	2005-09-10 03:25:51.000000000 -0500
@@ -54,6 +54,12 @@
   KCmdLineArgs::addCmdLineOptions(options);
   KCmdLineArgs *arg = KCmdLineArgs::parsedArgs();
 
+  if( arg->isSet( "fork" ) )
+  {
+    if (fork())
+      exit(0);
+  }
+
   if ( !( arg->isSet( "dcop" ) ) )
     KApplication::disableAutoDcopRegistration();
   else if ( KApplication::dcopClient()->attach() )
@@ -69,18 +75,6 @@
       wndMain.setStartupItemCount( steps );
   }
 
-  // The position of this fork() matters, fork too early and you risk the
-  // calls to KSplash::programStarted being missed. Now that wndMain has
-  // been instantiated it is safe to do this. An earlier version of
-  // this program had this fork occuring before the instantiation,
-  // and this led to a race condition where if ksplash lost the race it would
-  // hang because it would wait for signals that had already been sent
-  if( arg->isSet( "fork" ) )
-  {
-    if (fork())
-      exit(0);
-  }
-
   app.setMainWidget(&wndMain);
   app.setTopWidget(&wndMain);
   return(app.exec());

Reply to: