Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 243474 - mail-filter/spamassassin - openrc-0.3.0-r1 always sees spamd as crashed
Summary: mail-filter/spamassassin - openrc-0.3.0-r1 always sees spamd as crashed
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Perl team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-23 20:11 UTC by Lars Wendler (Polynomial-C) (RETIRED)
Modified: 2010-04-20 13:16 UTC (History)
12 users (show)

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


Attachments
3.0.0-spamd.init.diff (3.0.0-spamd.init.diff,484 bytes, patch)
2008-12-22 15:15 UTC, Lars Wendler (Polynomial-C) (RETIRED)
Details | Diff
sleep if PID-file not yet created (spamd.patch,469 bytes, patch)
2009-03-07 16:14 UTC, Peter Alfredsen (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2008-10-23 20:11:57 UTC
Hi,

rc-status shows spamd as crashed although spamd is still running and happily munching spam-mails :)

Reproducible: Always

Steps to Reproduce:
1. emerge =openrc-0.3.0-r1 spamassassin
2. /etc/init.d/spamd start
3a. rc-status
3b. /etc/init.d/spamd status
Actual Results:  
# ps -A | grep spamd
13169 ?        00:00:00 spamd
13172 ?        00:00:00 spamd
13173 ?        00:00:00 spamd
barcelona:~ # rc-status | grep spamd
 spamd                                                          [  crashed  ]
barcelona:~ # /etc/init.d/spamd status
 * status: crashed
barcelona:~ #

Expected Results:  
barcelona:~ # rc-status | grep spamd
 spamd                                                          [  started  ]
barcelona:~ # /etc/init.d/spamd status
 * status: started
barcelona:~ #

# emerge --info
Portage 2.2_rc12 (default/linux/amd64/2008.0/desktop, gcc-4.3.2, glibc-2.7-r2, 2.6.27.3 x86_64)
=================================================================
System uname: Linux-2.6.27.3-x86_64-Quad-Core_AMD_Opteron-tm-_Processor_2354-with-glibc2.2.5
Timestamp of tree: Thu, 23 Oct 2008 18:00:01 +0000
ccache version 2.4 [disabled]
app-shells/bash:     3.2_p39
dev-java/java-config: 1.3.7, 2.1.6-r1
dev-lang/python:     2.5.2-r8
dev-util/ccache:     2.4-r8
dev-util/cmake:      2.6.2
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.3.0-r1
sys-apps/sandbox:    1.2.18.1-r3
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.1-r1
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.25-r4
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=barcelona -mtune=barcelona -O2 -finline-functions -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config"
CONFIG_PROTECT_MASK="/etc/X11/Sessions /etc/X11/app-defaults /etc/X11/xinit /etc/bash_completion.d /etc/bonobo-activation /etc/ca-certificates.conf /etc/cups /etc/dbus-1 /etc/env.d /etc/env.d/java/ /etc/eselect/compiler /etc/fish /etc/fonts /etc/fonts/fonts.conf /etc/foomatic /etc/gconf /etc/gentoo-release /etc/gimp /etc/gnome-vfs-2.0 /etc/gtk /etc/gtk-2.0 /etc/hotplug /etc/hotplug.d /etc/imlib /etc/init.d /etc/iproute2 /etc/nas /etc/ntop /etc/pam.d /etc/pango /etc/profile.d /etc/revdep-rebuild /etc/sasl2 /etc/sgml /etc/ssl /etc/ssmtp /etc/t1lib /etc/terminfo /etc/udev/rules.d /etc/xinetd.d /etc/xml /etc/zsh"
CXXFLAGS="-march=barcelona -mtune=barcelona -O2 -finline-functions -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--alphabetical --jobs=1 --with-bdeps=y"
FEATURES="collision-protect distlocks parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch userpriv usersandbox"
GENTOO_MIRRORS="ftp://linux.rz.ruhr-uni-bochum.de/gentoo-mirror ftp://ftp.tu-clausthal.de/pub/linux/gentoo http://distfiles.gentoo.org http://www.ibiblio.org/pub/Linux/distributions/gentoo"
LDFLAGS="-Wl,-O1,--hash-style=gnu,--sort-common,--as-needed"
LINGUAS="de"
MAKEOPTS="-j7"
PKGDIR="/usr/portage/packages"
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/local/portage"
SYNC="rsync://192.168.0.254/gentoo-portage"
USE="3dnow 3dnowext X a52 aac acpi alsa amd64 amd64codecs asf avi berkdb branding bzip2 cairo cdparanoia cdr cli cracklib crypt cups dvd dvdr dvdread emboss encode fam ffmpeg flac gdbm gif gnutls gpg gtk gtk2 iconv idn imagemagick imlib isdnlog jpeg jpeg2k kde kdehiddenvisibility lame libwww mad midi mikmod mjpeg mmx mmxext mp3 mpeg mudflap multilib ncurses nls nptl nptlonly nsplugin ogg oggvorbis opengl pam pcre pdf png pppd qt3 qt3support quicktime readline reflection sdl session silc slang smp spell spl sse sse2 ssl startup-notification svg sysfs tga theora threads tiff truetype usb v4l2 vcd vorbis x264 xcomposite xml xml2 xorg xprint xulrunner xv xvid zlib" ALSA_CARDS="emu10k1 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" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LINGUAS="de" USERLAND="GNU" VIDEO_CARDS="nv nvidia"
Unset:  CPPFLAGS, CTARGET, FFLAGS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Thomas Sachau gentoo-dev 2008-10-24 13:12:20 UTC
Which of the both ebuilds did you update before this problem appeared?
Comment 2 Mike Auty (RETIRED) gentoo-dev 2008-10-25 10:52:59 UTC
Also note, denyhosts gets reported as crashed immediately after startup, even though it's still running.  It may just be related to the way openrc determines whether a service is still running or not.  My guess is that the parent process forks a child and then immediately dies, which openrc classes as an immediate death (even though the exit code is 0) and marks it as crashed.
Comment 3 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2008-10-26 07:27:50 UTC
IIRC that must be openrc from version 0.2.5 to 0.3.0-r1 which was the last update of both packages.
But I cannot say for sure that openrc-0.2.5 did not see spamd as crashed...
Comment 4 Roy Marples 2008-10-30 13:13:51 UTC
spamd is a bitch
1) It's a perl daemon
2) Possibly because of 1, but anyway, it changes /proc/$pid/cmdline to non standard foo
3) The init script should not use name
4) the init script should use a pidfile

        start-stop-daemon --start --quiet \
                --nicelevel ${SPAMD_NICELEVEL:-0} \
                --pidfile ${PIDFILE} \
                --exec /usr/sbin/spamd -- -d -r ${PIDFILE} "" \
                        ${SPAMD_OPTS}

There we go.
Now s-s-d has a pidfile to work with, spamd works fine. There is a small window between s-s-d returning AND spamd writing the pidfile (which is bad - fix spamd) but that's the best we can do.
Comment 5 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2008-12-22 15:15:42 UTC
Created attachment 176154 [details, diff]
3.0.0-spamd.init.diff

Here's a patch that incorporates Roy's suggestions.
Comment 6 Doug Goldstein (RETIRED) gentoo-dev 2009-02-05 17:23:05 UTC
The bug is with spamassassin's init script. Assigning to perl herd since they maintain that.
Comment 7 Peter Alfredsen (RETIRED) gentoo-dev 2009-03-07 16:14:57 UTC
Created attachment 184236 [details, diff]
sleep if PID-file not yet created

As Roy mentioned there is a small window of opportunity for a race condition with this patch, which breaks repeated restarts. This patch sleeps for 1 second till
Comment 8 Nathan Phillip Brink (binki) (RETIRED) gentoo-dev 2009-03-21 02:11:48 UTC
(In reply to comment #7)
> Created an attachment (id=184236) [edit]
> sleep if PID-file not yet created
> 
On my machine, I just disable'd spamd's daemonization. Removing the -d argument for spamd and adding --background to openrc's arguments allows my spamd service to start. I suppose that not waiting for spamd to start up, create its sockets, and create its pidfile is asking for trouble with services that use spamd (like spamass-milter). But I think it's better than the potentially infinite loop suggested by this patch (if spamd writes its pidfile and then dies and removes the pidfile while the script sleeps, or if spamd errors before creating the pidfile).
I use mail-filter/spamassassin-3.2.5 and sys-apps/openrc-0.4.3-r1. I first had the error message ``start-stop-daemon: /usr/sbin/spamd died'' when trying to start spamd after upgrading from mail-filter/spamassassin-3.2.1-r1. I have experienced the same problem, where the daemon starts but openrc says it has died, with net-im/ejabberd-2.0.2-r1 (and haven't gotten the courage to pursue that issue yet :-) ).
Comment 9 boris64 2009-06-19 13:52:12 UTC
The solution mentionened in comment #8 works fine for me.
Will this "officially" be fixed some day?
Comment 10 Torsten Veller (RETIRED) gentoo-dev 2009-12-25 10:01:06 UTC
(In reply to comment #7)
> Created an attachment (id=184236) [details]
> sleep if PID-file not yet created

| +	if ! [ -f "${PIDFILE}" ]; then
| +		sleep 1
| +	fi
|  	eend $? "Failed to start spamd"

After this change, testing for $? isn't useful anymore.
Comment 11 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2010-04-12 15:34:41 UTC
(In reply to comment #10)
> (In reply to comment #7)
> > Created an attachment (id=184236) [details] [details]
> > sleep if PID-file not yet created
> 
> | +     if ! [ -f "${PIDFILE}" ]; then
> | +             sleep 1
> | +     fi
> |       eend $? "Failed to start spamd"
> 
> After this change, testing for $? isn't useful anymore.

Yeah. spamassassin-3.3.1 had exactly that error but it got fixed in bug #313599. By the way spamassassin-3.3.1 doesn't suffer from this bug anymore so I suggest we can close it as fixed.
Comment 12 David Abbott (RETIRED) gentoo-dev 2010-04-20 13:16:30 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > (In reply to comment #7)
> > > Created an attachment (id=184236) [details] [details] [details]
> > > sleep if PID-file not yet created
> > 
> > | +     if ! [ -f "${PIDFILE}" ]; then
> > | +             sleep 1
> > | +     fi
> > |       eend $? "Failed to start spamd"
> > 
> > After this change, testing for $? isn't useful anymore.
> 
> Yeah. spamassassin-3.3.1 had exactly that error but it got fixed in bug
> #313599. By the way spamassassin-3.3.1 doesn't suffer from this bug anymore so
> I suggest we can close it as fixed.
> 

new init script seems to have fixed it, closing thanks