Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 261359 - x11-misc/slim does not stop with /etc/init.d/xdm stop or restart
Summary: x11-misc/slim does not stop with /etc/init.d/xdm stop or restart
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High major with 1 vote (vote)
Assignee: Jeremy Olexa (darkside) (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-05 20:26 UTC by Sebastian Günther
Modified: 2010-08-24 17:45 UTC (History)
15 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Don't catch SIGKILL (doesn't fix the bug, though) (slim-1.3.1-sigkill.patch,897 bytes, patch)
2009-10-08 17:32 UTC, Jeroen Roovers (RETIRED)
Details | Diff
remove the hanging XCloseDisplay() --not a proper fix (slim-1.3.1-shutdown.patch,362 bytes, text/plain)
2010-03-22 13:43 UTC, Ian Stakenvicius (RETIRED)
Details
Never block in XNextEvent() function (261359-fix-SIGTERM-freeze.patch,1.13 KB, patch)
2010-05-22 21:18 UTC, Grygoriy I. Fuchedzhy
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Günther 2009-03-05 20:26:51 UTC
Every time I try to stop slim with #/etc/init.d/xdm stop, it fails. I have to manually kill X and slim to really stop it.

But this leaves a stale lockfile...

There is the same problem when shutting down the system from console by any means.

There is no problem when shutting down via slims special user "halt".


Reproducible: Always

Steps to Reproduce:
1. /etc/init.d/xdm stop -> fails
2. killall X; killall -9 slim
3. /etc/init.d/xdm stop -> now works



Expected Results:  
/etc/init.d/xdm stop runs without failure.

Portage 2.2_rc23 (default/linux/x86/2008.0/desktop, gcc-4.3.3, glibc-2.9_p20081201-r2, 2.6.28-tuxonice-r3 i686)
=================================================================
System uname: Linux-2.6.28-tuxonice-r3-i686-Intel-R-_Core-TM-_Duo_CPU_T2300_@_1.66GHz-with-glibc2.0
Timestamp of tree: Wed, 04 Mar 2009 22:45:02 +0000
ccache version 2.4 [enabled]
app-shells/bash:     3.2_p48-r1
dev-java/java-config: 2.1.7
dev-lang/python:     2.5.4-r2
dev-python/pycrypto: 2.0.1-r7
dev-util/ccache:     2.4-r8
dev-util/cmake:      2.6.2-r1
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.4.3-r1
sys-apps/sandbox:    1.3.8
sys-devel/autoconf:  2.13, 2.63
sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2
sys-devel/binutils:  2.19.1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.28-r1
ACCEPT_KEYWORDS="x86 ~x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/eselect/postgresql /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="ccache distlocks fixpackages parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://mirror.netcologne.de/gentoo/ http://ftp.uni-erlangen.de/pub/mirrors/gentoo http://de-mirror.org/distro/gentoo/ http://mirror.cambrium.nl/pub/os/linux/gentoo/ http://mirror.muntinternet.net/pub/gentoo/"
LANG="de_DE"
LC_ALL="de_DE"
LDFLAGS="-Wl,-O1"
LINGUAS="de fr nl en en_GB en_US"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--exclude-from=/etc/portage/rsync_excludes"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage/local/layman/swegener /usr/portage/local/local-overlay"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="7zip X a52 aac abook ace acl acpi alsa applet audacious audiofile bash-completion battery berkdb bluetooth branding bzip2 cairo caps cdda cddb cdparanoia cdr cgi chipcard cli compress context cpio cpufreq cracklib crypt cups curl cursors dbus device-mapper dga directfb divx djvu doc dri dv dvd dvdr dvdread dvi emacs emboss emerald encode epydoc examples exif expat extra fam fastcgi fat fbcon fbcondecor fbsplash ffmpeg flac fontconfig fortran ftp fuse gcj gd gdbm gdm gedit gif gimp glib glitz gmedia gnutls gpgme gpm grace graphics graphviz gs gtk gzip hal hbci hdaps hddtemp http humanities hybrid-auth ibmacpi icecast icons iconv icq icu id3 id3tag imagemagick imap imlib imlib2 iproute2 ipv6 ipw3945 irc isdnlog jabber java java6 javascript jpeg kerberos kpathsea ladspa lame laptop latex lcms ldap libnotify libsamplerate libwww lm_sensors logrotate logwatch lua mad midi mikmod milter mime mjpeg mmx mmxext mng motif mp3 mpeg mplayer mudflap musepack musicbrainz nano-syntax ncurses network-cron nls nntp nptl nptlonly nsplugin ntfs ntp obex offensive ofx ogg omega opengl openmp oscar pam pcmcia pcre pda pdf perl php pmu png pop posix postgres ppds pppd prediction print pstricks publishers python qt3 qt3support qt4 quicktime quotes rar rdesktop readline realmedia reflection replaygain replytolist resolvconf rpm rss samba sasl science sdl session skey slang slit smapi smime smp snmp sockets socks5 sound soundtouch speex spell spl sqlite sqlite3 sse sse2 ssh ssl startup-notification subtitles subversion svg swig sysfs syslog sysvipc t1lib taglib tcpd tetex tex4ht theora threads tiff toolbar tools transcode trayicon truetype twolame unicode unzip usb utils uuencode v4l v4l2 vamp vcd vhosts video vnc vncviewer vorbis wavpack wifi win32codecs wireshark wma wmf wmp x86 xattr xcb xcomposite xetex xface xfce xft xine xinerama xinetd xml xorg xosd xpm xscreensaver xskatcards xspf xulrunner xv xvid yv12 zip zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CAMERAS="canon ptp2" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de fr nl en en_GB en_US" USERLAND="GNU" VIDEO_CARDS="vesa intel v4l vga i810"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS
Comment 1 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2009-03-05 21:26:33 UTC
Try 
  /etc/init.d/xdm zap
after you killed X manually. Of course this is only some "workaround" until there's found some better solution.

Reassigning to slim maintainer, CCing desktop-misc herd, CCing x11 herd as well as xdm init script belongs to x11-apps/xinit package.
Comment 2 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-03-05 22:23:43 UTC
Probably related to bug 186886. I can't reliably reproduce this issue either. =/
Comment 3 Sebastian Günther 2009-03-06 08:49:43 UTC
OK, since I can reproduce it easily:

I will dig into it later on. Any more informations that I can provide which might help on finding the causes of this?
Comment 4 Sebastian Günther 2009-03-06 12:31:56 UTC
In the log file this message shows up, when using the xdm init script to stop:
(BTW: why does slim log all X messages, too?)

slim: unexpected signal 15

I did an strace and after the first try to stop it, nothing more happens at the strace

strace log follows:

Process 12001 attached - interrupt to quit
select(5, [4], [], NULL, NULL)          = ? ERESTARTNOHAND (To be restarted)
--- SIGALRM (Alarm clock) @ 0 (0) ---
waitpid(12005, NULL, WNOHANG)           = 0
rt_sigaction(SIGALRM, {0x8068280, [ALRM], SA_RESTART}, {0x8068280, [ALRM], SA_RESTART}, 8) = 0
alarm(2)                                = 0
sigreturn()                             = ? (mask now [])
select(5, [4], [], NULL, NULL)          = ? ERESTARTNOHAND (To be restarted)
--- SIGALRM (Alarm clock) @ 0 (0) ---
waitpid(12005, NULL, WNOHANG)           = 0
rt_sigaction(SIGALRM, {0x8068280, [ALRM], SA_RESTART}, {0x8068280, [ALRM], SA_RESTART}, 8) = 0
alarm(2)                                = 0
sigreturn()                             = ? (mask now [])
select(5, [4], [], NULL, NULL)          = ? ERESTARTNOHAND (To be restarted)
--- SIGTERM (Terminated) @ 0 (0) ---
write(2, "slim"..., 4)                  = 4
write(2, ": unexpected signal "..., 20) = 20
write(2, "15"..., 2)                    = 2
write(2, "\n"..., 1)                    = 1
alarm(0)                                = 1
rt_sigaction(SIGQUIT, {0x1, [QUIT], SA_RESTART}, {0x8068300, [QUIT], SA_RESTART}, 8) = 0
rt_sigaction(SIGINT, {0x1, [INT], SA_RESTART}, {0x8068300, [INT], SA_RESTART}, 8) = 0
rt_sigaction(SIGHUP, {0x1, [HUP], SA_RESTART}, {0x8068300, [HUP], SA_RESTART}, 8) = 0
rt_sigaction(SIGPIPE, {0x1, [PIPE], SA_RESTART}, {0x8068300, [PIPE], SA_RESTART}, 8) = 0
rt_sigaction(SIGTERM, {SIG_DFL, [TERM], SA_RESTART}, {0x8068300, [TERM], SA_RESTART}, 8) = 0
rt_sigaction(SIGKILL, {SIG_DFL, [KILL], SA_RESTART}, {0x8068300, [TERM], SA_RESTART}, 8) = -1 EINVAL
 (Invalid argument)
rt_sigaction(SIGALRM, {SIG_DFL, [ALRM], SA_RESTART}, {0x8068280, [ALRM], SA_RESTART}, 8) = 0
select(5, [4], [4], NULL, NULL)         = 1 (out [4])
writev(4, [{"<\0\2\0\0\0@\0+\0\1\0"..., 12}], 1) = 12
+++ killed by SIGKILL +++
Comment 5 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-03-10 04:50:59 UTC
thx, I'm not sure what this tells me but I should be able to revisit it sometime.
Comment 6 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-03-25 23:56:37 UTC
*** Bug 261682 has been marked as a duplicate of this bug. ***
Comment 7 Nico R. Wohlgemuth 2009-06-19 12:29:13 UTC
I can't even start slim. Though DISPLAYMANAGER in /etc/conf.d/xdm is set to "slim", the script always tries to execute xdm and not slim. :/ 
Comment 8 Nico R. Wohlgemuth 2009-06-20 11:30:52 UTC
I think the code from /etc/init.d/xdm lines 92-99 fails hard.

I work around the problem by changing 
EXE= to /usr/bin/slim in the init.d file
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2009-10-08 17:32:28 UTC
Created attachment 206465 [details, diff]
Don't catch SIGKILL (doesn't fix the bug, though)

(In reply to comment #4)
> rt_sigaction(SIGKILL, {SIG_DFL, [KILL], SA_RESTART}, {0x8068300, [TERM],
> SA_RESTART}, 8) = -1 EINVAL

It shouldn't even try to catch SIGKILL. The patch should fix that, but doesn't fix the bug.
Comment 10 Andrew Stimpson 2009-10-10 22:19:41 UTC
From some rambling found on a Madriva bug report, I discovered that if one manually kills the X session, then /etc/init.d/xdm will successfully shutdown slim.

This is almost certainly an upstream problem, but they have "high priority" bugs on their bug tracker that are over a year old:

http://developer.berlios.de/bugs/?group_id=2663

So I doubt anything will be fixed anytime soon.  Any suggestions for another lightweight login manager?
Comment 11 Tomáš Chvátal (RETIRED) gentoo-dev 2009-10-10 22:22:49 UTC
Orthos, in sunrise :]
Comment 13 Pete Hildebrandt 2010-03-12 21:27:08 UTC
I did some testing on this bug and I could narrow it down a little.
Stoping slim fails when calling XCloseDisplay(Dpy);
Calling XCloseDisplay(Dpy); never returns and slim uses up all the CPU, never coming to an and.

As a quick and dirty hack it helps to comment-out XCloseDisplay(Dpy); in the StopServer Routine. But it's not a fix, it just lets slim come to an end.

I didn't have time yet to dig deeper to find out where it hangs when calling XCloseDisplay(Dpy);
Comment 14 Ian Stakenvicius (RETIRED) gentoo-dev 2010-03-22 13:43:06 UTC
Created attachment 224675 [details]
remove the hanging XCloseDisplay() --not a proper fix

This is the patch I used to do the above -- as mentioned previously, it works because slim completes its shutdown call now, but it's still not a proper fix.
Comment 15 Doktor Notor 2010-03-22 14:02:49 UTC
(In reply to comment #14)
> This is the patch I used to do the above -- as mentioned previously, it works
> because slim completes its shutdown call now, but it's still not a proper fix.

Thanks. Will try, kill -9 is not a proper fix either, so can't be worse *g* 

Comment 16 Grygoriy I. Fuchedzhy 2010-05-22 13:10:41 UTC
I can stop xdm without errors if I had logged in using slim.
If I try to stop it before logging in I get blocking call to XCloseDisplay() which was called from:
  CatchSignal() -> App::StopServer() -> XCloseDisplay()

I tried to track this problem and I've found why XCloseDisplay() blocks.
Here is call stack for the moment of time when slim waits for input:
  App::Run() -> App::AuthenticateUser() -> PAM::Authenticator::authenticate() -> pam_authenticate() -> ... -> conv() -> Panel::EventHandler() -> XNextEvent()

XNextEvent() is actually blocking function waiting for input. XCloseDisplay() is called in the middle of XNextEvent() call which is terribly wrong.

So we should somehow gracefully terminate XNextEvent() from signal handler and only after that call App::StopServer()
Comment 17 Grygoriy I. Fuchedzhy 2010-05-22 21:18:23 UTC
Created attachment 232517 [details, diff]
Never block in XNextEvent() function
Comment 18 Grygoriy I. Fuchedzhy 2010-05-22 21:23:59 UTC
I have added patch which should fix this problem. It works fine for me. Please test.
This patch makes slim never call XNextEvent() if there is no event in queue. So XCloseDisplay() can be called from signal handler.
Comment 19 James Harvey 2010-08-14 03:33:40 UTC
(In reply to comment #18)
> I have added patch which should fix this problem. It works fine for me. Please
> test.
> This patch makes slim never call XNextEvent() if there is no event in queue. So
> XCloseDisplay() can be called from signal handler.
> 

I can verify this patch worked for me as well. Using:

slim 1.3.2
xorg-server-1.7.6
gentoo-sources-2.6.35-r1
ati-drivers-10.7

perhaps the maintainer could add this to portage?
Comment 20 Elias Gabriel Amaral da Silva 2010-08-23 03:59:34 UTC
I thought the problem was that slim has /var/run/slim.{auth,lock} and /etc/init.d/xdm expects /var/run/slim.pid ..
Comment 21 Gef 2010-08-23 06:57:57 UTC
(In reply to comment #20)
> I thought the problem was that slim has /var/run/slim.{auth,lock} and
> /etc/init.d/xdm expects /var/run/slim.pid ..
> 

So do I. I use a slightly modified init.d/xdm:

@@ -71,6 +70,10 @@
 			EXE="/usr/kde/${MY_XDM#kdm-}/bin/kdm"
 			PIDFILE=/var/run/kdm.pid
 			;;
+		slim)
+			EXE="$(which slim)"
+			PIDFILE=/var/run/slim.lock
+			;;
 		entrance*)
 			EXE=/usr/sbin/entranced
 			PIDFILE=/var/lib/entranced.pid

Comment 22 Ian Stakenvicius (RETIRED) gentoo-dev 2010-08-23 20:41:12 UTC
The patch in Attachment 323517 fixed the problem on my system as well.. (slim-1.3.2 on x86)

I have a similar entry in my /etc/init.d/xdm , although instead of $(which slim) I just have /usr/bin/slim
Comment 23 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-08-23 21:32:04 UTC
(In reply to comment #17)
> Created an attachment (id=232517) [details]
> Never block in XNextEvent() function
> 

Will someone post this patch upstream?
Comment 24 Ian Stakenvicius (RETIRED) gentoo-dev 2010-08-24 15:08:46 UTC
(In reply to comment #23)
> (In reply to comment #17)
> > Created an attachment (id=232517) [details] [details]
> > Never block in XNextEvent() function
> > 
> 
> Will someone post this patch upstream?
> 

Upstream already has the bug listed at http://developer.berlios.de/bugs/?func=detailbug&bug_id=15326&group_id=2663 -- i just added a comment to it pointing to this discussion as well as the patch.
Comment 25 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-08-24 15:31:46 UTC
Thanks all. Please file new bug reports in lieu of re-opening this one.

+*slim-1.3.2-r1 (24 Aug 2010)
+
+  24 Aug 2010; Jeremy Olexa <darkside@gentoo.org>
+  +files/261359-fix-SIGTERM-freeze.patch, +slim-1.3.2-r1.ebuild,
+  +files/slim-1.3.2-r1-config.diff:
+  Revision bump which should improve shutdown behavior by patching a SIGTERM
+  issue and changing the pid file to slim.pid instead of slim.lock. Thanks
+  to Grygoriy I. Fuchedzhy and others in bug 261359
Comment 26 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-08-24 15:33:43 UTC
Sorry, forgot to mention that /etc/init.d/xdm should work without manual patching now as long as DISPLAYMANAGER=slim in /etc/conf.d/xdm
Comment 27 Gef 2010-08-24 17:45:55 UTC
(In reply to comment #21)
> (In reply to comment #20)
> > I thought the problem was that slim has /var/run/slim.{auth,lock} and
> > /etc/init.d/xdm expects /var/run/slim.pid ..
> > 
> 
> So do I. I use a slightly modified init.d/xdm:

I realized that it should not be necessary to modify the init script as slim.conf has an appropriate directive whose value just need to be gentoo-ified:

-------------------------------------------
# Lock file
#lockfile            /var/run/slim.lock
lockfile            /var/run/slim.pid
-------------------------------------------