Bug 4138 - spamd hanging on infinite loop
Summary: spamd hanging on infinite loop
Status: RESOLVED WORKSFORME
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamc/spamd (show other bugs)
Version: 3.0.2
Hardware: PC Linux
: P3 major
Target Milestone: 3.1.1
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords: moreinfo, triage
Depends on:
Blocks:
 
Reported: 2005-02-15 08:49 UTC by Henk van Lingen
Modified: 2011-10-05 19:42 UTC (History)
1 user (show)



Attachment Type Modified Status Actions Submitter/CLA Status
Email message triggering the problem text/plain None Henk van Lingen [NoCLA]
bayes_seen file application/octet-stream None Henk van Lingen [NoCLA]
bayes_toks gzipped file application/x-gzip None Henk van Lingen [NoCLA]
debug output spamd -D -d -c -m5 -H text/plain None Henk van Lingen [NoCLA]
output spamassassin -D --lint (runned as the affected user) text/plain None Henk van Lingen [NoCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Henk van Lingen 2005-02-15 08:49:16 UTC
I'm using SA 3.0.2 on a CentOS 3.4 Linux system in a spamd/spamc setup.
spamc is called via 'maildrop' with user privileges. Now the problem is,
I have a message in my queue (postfix) that seems to hang spamd. Every time
it tries local delivery, spamc times out after 10 minutes but the spamd
child is going on using the CPU forever, without doing any syscalls.
The last thing spamd is telling in debug mode is it is doing 'tokenize:'
steps.
It's not specific to one message, and there are also messages succeeding for 
the same user. The problem is related to the bayes* files in the users
$HOME/.spamassassin/ directory. Erasing them fixes the problem. Setting the
old files back reintroduces the problem. A sa-learn --backup and a --restore
also seems to fix the problem.
So the bug is no showstopper, but I think even feeding random bits to my Bayes
database shouldn't make a spamd go wild.

BTW: if one sends the hanging spamd child a TERM, it is terminated
nicely and the parent spawns a new child.

I can reproduce the problem with the bayes files and a mail file which I will
attach to this ticket.
Comment 1 Michael Parker 2005-02-15 08:53:44 UTC
Is it trying to do an expire (are their *.expire* files in the .spamassassin dir)?
Comment 2 Henk van Lingen 2005-02-15 08:57:14 UTC
Created attachment 2651 [details]
Email message triggering the problem
Comment 3 Henk van Lingen 2005-02-15 08:58:21 UTC
Created attachment 2652 [details]
bayes_seen file
Comment 4 Henk van Lingen 2005-02-15 09:01:02 UTC
Can't attach bayes_toks:

"The file you are trying to attach is 1232 kilobytes (KB) in size. Non-patch
attachments cannot be more than 1000 KB."
Comment 5 Michael Parker 2005-02-15 09:05:22 UTC
Subject: Re:  spamd hanging on infinite loop

Also, possibly you've got a corrupted bayes db file.

Try compressing with gzip or bzip2.  If it's a corrupted bayes file,
it will be required to debug.

Comment 6 Henk van Lingen 2005-02-15 09:06:27 UTC
(In reply to comment #1)
> Is it trying to do an expire (are their *.expire* files in the .spamassassin dir)?

No, no such files around.

Comment 7 Henk van Lingen 2005-02-15 09:34:33 UTC
Created attachment 2653 [details]
bayes_toks gzipped file
Comment 8 Michael Parker 2005-02-15 09:52:36 UTC
Subject: Re:  spamd hanging on infinite loop

Attached message causes no problem on my stock 3.0.2 install, with my
own bayes db.

Does it slow down when using spamassassin or only spamd/spamc?
Comment 9 Henk van Lingen 2005-02-15 09:57:39 UTC
(In reply to comment #8)
> Subject: Re:  spamd hanging on infinite loop
> 
> Attached message causes no problem on my stock 3.0.2 install, with my
> own bayes db.

That's right. You both need the message and the db files to reproduce the
problem.

> Does it slow down when using spamassassin or only spamd/spamc?

I didn't try spamassassin, only spamd/spamc. 
Comment 10 Michael Parker 2005-02-15 09:59:17 UTC
Subject: Re:  spamd hanging on infinite loop

> 
> I didn't try spamassassin, only spamd/spamc. 
> 

Can you please capture some debug output (via -D) , with the broken
bayes dbs in place for spamd and spamassassin?
Comment 11 Henk van Lingen 2005-02-15 10:16:11 UTC
Created attachment 2654 [details]
debug output spamd -D -d -c -m5 -H
Comment 12 Michael Parker 2005-02-15 10:19:46 UTC
Subject: Re:  spamd hanging on infinite loop

Also, output from spamassassin -D --lint

Thanks
Michael
Comment 13 Henk van Lingen 2005-02-15 11:22:27 UTC
Created attachment 2655 [details]
output spamassassin -D --lint (runned as the affected user)
Comment 14 Henk van Lingen 2005-02-16 07:07:47 UTC
I've started a little poor man's debugging myself:

It gets stuck writing to the bayes_seen hash. From learn_trapped, it succeeds
tokenizing, stores the tokens, calls $self->{store}->seen_put , seen_put_direct
and than hangs on the line:

$self->{db_seen}->{$msgid} = $seen;

called with the values b9eccae48c5e4921fcffbe305d11195f1953e45a@sa_generated, h

Cheers,

Comment 15 Michael Parker 2005-05-24 15:31:23 UTC
This really looks like a corrupt bayes_seen db file.  Did you already rm the old
files and start from scratch?
Comment 16 Bob Menschel 2005-07-13 23:34:59 UTC
Michael, "This really looks like a corrupt bayes_seen db file.  Did you already
rm the old files and start from scratch?" Per the original report, "Erasing them
fixes the problem. Setting the old files back reintroduces the problem. A
sa-learn --backup and a --restore also seems to fix the problem." 

Henk, after you've deleted the Bayes files, does the problem come back, or is it
gone for good?  

If it comes back, then if it is caused by Bayes corruption, there's a problem
that's /causing/ the corruption that should be looked into, if possible. 

Even so, why would /this/ message aggravate the corruption and cause a
spamd/spamc hang, but not most others? 

Henk, you included the debug output from spamd, which ends with the header
tokenize. I don't know spamd well enough to know whether there should then be
body tokenize lines.  It might be that tokenize is failing on the body. Perhaps
on those long lines of encoded equal signs? 

You attached a "spamassassin -D --lint", but not a "spamassassin -D <message"
output.  Can you do that latter, so we can compare the two debug outputs as they
actually attempt to process the message, the same message, against the same
problematic bayes files? 
Comment 17 Justin Mason 2005-10-14 09:42:13 UTC
closing WORKSFORME until we hear more.
typically hangs when writing a value to a Berkeley DB file are indicative of:

(a) corrupt db files
(b) or bugs in that library, which we cannot fix
Comment 18 spamassassin 2006-06-04 21:34:13 UTC
Supposing this is the same bug as the Debian bug 295451, it may be a matter of
passing O_EXCL to DB_File.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295451
Comment 19 Darxus 2011-10-05 19:42:25 UTC
Closing WORKSFORME, again.  Hasn't been updated in 5 years.  Target is 3.1.1.