Bug 181242 - mail/p5-Mail-SpamAssassin 3.3.2 crashes with Perl 5.14.* - Bug fixed in 3.4
Summary: mail/p5-Mail-SpamAssassin 3.3.2 crashes with Perl 5.14.* - Bug fixed in 3.4
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Beech Rintoul
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-12 21:00 UTC by spamd-pr
Modified: 2013-09-03 16:08 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description spamd-pr 2013-08-12 21:00:02 UTC
Versions of SpamAssassin prior to 3.4 crash with Perl 5.14.*, or at least the most recent version in the ports collection (3.3.2 downloaded on July 10, 2013).

(I am not the only one who experienced it after the Perl upgrade, google it for many reports).

According to this bug 6745, this issue has been fixed in 3.4.
https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6745

A a few examples of the log messages
(from /var/log/maillog) of how SpamAssassin crashes:
/var/log/maillog.1.bz2:Aug  6 18:11:30 <mail.err> trantor spamd[78473]:
Out of memory during ridiculously large request at
/usr/local/lib/perl5/site_perl/5.14/Mail/SpamAssassin/Logger.pm line 239.
/var/log/maillog.3.bz2:Aug  4 20:35:09 <mail.err> trantor spamd[90636]:
Out of memory during ridiculously large request at
/usr/local/lib/perl5/site_perl/5.14/Mail/SpamAssassin/Logger.pm line 224.
/var/log/maillog.7.bz2:Jul 31 09:47:49 <mail.err> trantor spamd[13669]:
Out of memory during ridiculously large request at
/usr/local/lib/perl5/site_perl/5.14/Mail/SpamAssassin/Logger.pm line 239.

Fix: 

According to SpamAssassin Forum, ver. 3.4  fixes the problem.
I have not checked that myself.

I hope that either this fix can be applied to the current 3.3.* version in ports (preferred), or the new version can be ported.
How-To-Repeat: 
Due to the large volume of e-mail messages I was not able to catch the offending message.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-08-13 04:09:03 UTC
Responsible Changed
From-To: freebsd-ports-bugs->beech

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 azverev 2013-08-20 11:35:31 UTC
Hello,

Can you to try this patch:
http://az.semmy.ru/sa/patch-bug6745 (same patch as in upstream fix) and
put in under ports/mail/p5-Mail-SpamAssassin/files
And after rebuild port to apply patch and confirm what patch helps.
Comment 3 spamd-pr 2013-08-20 18:22:08 UTC
Hello, Andrey!

Thank you, I applied your patch to the port, and installed the newly 
compiled port. 
However, the crash events are not frequent, and I cannot catch the 
offending message(s) (see below).

I will try to report in 1-2 week if I don't see anything in the 
logs, or earlier, if I notice something.


> bzfgrep "Out of memory during ridiculously large request" 
/var/log/maillog.*
/var/log/maillog.10.bz2:Aug  9 10:16:06 <mail.err> trantor spamd[42882]: 
Out of memory during ridiculously large request at 
/usr/local/lib/perl5/site_perl/5.14/Mail/SpamAssassin/Logger.pm line 224.
/var/log/maillog.10.bz2:Aug  9 15:47:14 <mail.err> trantor spamd[47875]: 
Out of memory during ridiculously large request at 
/usr/local/lib/perl5/site_perl/5.14/Mail/SpamAssassin/Logger.pm line 224.
/var/log/maillog.11.bz2:Aug  8 14:03:27 <mail.err> trantor spamd[23541]: 
Out of memory during ridiculously large request at 
/usr/local/lib/perl5/site_perl/5.14/Mail/SpamAssassin/Logger.pm line 224.
/var/log/maillog.13.bz2:Aug  6 18:11:30 <mail.err> trantor spamd[78473]: 
Out of memory during ridiculously large request at 
/usr/local/lib/perl5/site_perl/5.14/Mail/SpamAssassin/Logger.pm line 239.
/var/log/maillog.15.bz2:Aug  4 20:35:09 <mail.err> trantor spamd[90636]: 
Out of memory during ridiculously large request at 
/usr/local/lib/perl5/site_perl/5.14/Mail/SpamAssassin/Logger.pm line 224.
/var/log/maillog.19.bz2:Jul 31 09:47:49 <mail.err> trantor spamd[13669]: 
Out of memory during ridiculously large request at 
/usr/local/lib/perl5/site_perl/5.14/Mail/SpamAssassin/Logger.pm line 239.
/var/log/maillog.6.bz2:Aug 13 03:14:37 <mail.err> trantor spamd[20789]: 
Out of memory during ridiculously large request at 
/usr/local/lib/perl5/site_perl/5.14/Mail/SpamAssassin/Logger.pm line 224.



On Tue, 20 Aug 2013, Zverev Andrey wrote:

> Hello,
>
> Can you to try this patch:
> http://az.semmy.ru/sa/patch-bug6745 (same patch as in upstream fix) and
> put in under ports/mail/p5-Mail-SpamAssassin/files
> And after rebuild port to apply patch and confirm what patch helps.
>
Comment 4 azverev 2013-08-26 10:35:10 UTC
Igor, any news?
Comment 5 spamd-pr 2013-08-26 18:22:01 UTC
Andrey,

It's been close to 6 days since I applied the patch.
So far, I see no crashes.

However, that might not be representative: As you can 
see in the log excerpt, in my previous response, during 7 days between 
Aug 13 and Aug 20, before I applied your patch, there were no crashes.

I will let you know if it crashes.
(I understand that there is a desire to include this patch in time for 
9.2-RELEASE.)
Comment 6 azverev 2013-08-26 18:26:39 UTC
No rush and It's already late for 9.2.


-----Original Message-----
From: Igor Roshchin [mailto:spamd-pr@str.komkon.org]=20
Sent: Monday, August 26, 2013 9:22 PM
To: Zverev Andrey
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/181242: mail/p5-Mail-SpamAssassin 3.3.2 crashes with
Perl 5.14.* - Bug fixed in 3.4


Andrey,

It's been close to 6 days since I applied the patch.
So far, I see no crashes.

However, that might not be representative: As you can see in the log
excerpt, in my previous response, during 7 days between Aug 13 and Aug
20, before I applied your patch, there were no crashes.

I will let you know if it crashes.
(I understand that there is a desire to include this patch in time for
9.2-RELEASE.)
Comment 7 spamd-pr 2013-09-02 18:26:43 UTC
Within about 12 days since installing the patch, I do not see any crashes 
of the spamd on my system.
So, since this patch ia based on the one created for the upstream source, 
and people there had no problems, I think it solves the problem and it is 
good to go into the ports tree.

Thank you, Andrey!

Igor
Comment 8 dfilter service freebsd_committer freebsd_triage 2013-09-02 20:00:32 UTC
Author: az
Date: Mon Sep  2 19:00:24 2013
New Revision: 326056
URL: http://svnweb.freebsd.org/changeset/ports/326056

Log:
  - Fix issue when spamd crashes because of memory problems in Logger.pm
    For more details see Bug 6745
  - Do not bump portrevision since issue not global
  While I'm here:
  - convert to the new perl5 framework
  
  PR:		ports/181242
  Submitted by:	Igor Roshchin <spamd-pr@str.komkon.org>
  Tested by:	Igor Roshchin <spamd-pr@str.komkon.org>	(two weeks)
  Approved by:	maintainer (timeout)

Added:
  head/mail/p5-Mail-SpamAssassin/files/patch-bug6745   (contents, props changed)
Modified:
  head/mail/p5-Mail-SpamAssassin/Makefile

Modified: head/mail/p5-Mail-SpamAssassin/Makefile
==============================================================================
--- head/mail/p5-Mail-SpamAssassin/Makefile	Mon Sep  2 18:52:48 2013	(r326055)
+++ head/mail/p5-Mail-SpamAssassin/Makefile	Mon Sep  2 19:00:24 2013	(r326056)
@@ -25,7 +25,8 @@ RUN_DEPENDS:=	${BUILD_DEPENDS}
 
 CONFLICTS?=	ja-p5-Mail-SpamAssassin-[0-9]* p5-Mail-SpamAssassin-devel-[0-9]* p5-Mail-SpamAssassin-Alt-[0-9]*
 
-PERL_CONFIGURE=	5.12+
+USES=		perl5
+USE_PERL5=	configure
 USE_LDCONFIG=	yes
 DBDIR?=		/var/db
 ETCDIR?=	${PREFIX}/etc/mail/spamassassin

Added: head/mail/p5-Mail-SpamAssassin/files/patch-bug6745
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/mail/p5-Mail-SpamAssassin/files/patch-bug6745	Mon Sep  2 19:00:24 2013	(r326056)
@@ -0,0 +1,106 @@
+--- lib/Mail/SpamAssassin/Logger/Syslog.pm	2012/05/14 16:28:23	1338277
++++ lib/Mail/SpamAssassin/Logger/Syslog.pm	2012/05/14 16:31:09	1338278
+@@ -167,17 +167,21 @@
+   }
+   $msg = $timestamp . ' ' . $msg  if $timestamp ne '';
+ 
+-  # important: do not call syslog() from the SIGCHLD handler
+-  # child_handler().   otherwise we can get into a loop if syslog()
+-  # forks a process -- as it does in syslog-ng apparently! (bug 3625)
+-  $Mail::SpamAssassin::Logger::LOG_SA{INHIBIT_LOGGING_IN_SIGCHLD_HANDLER} = 1;
++# no longer needed since a patch to bug 6745:
++# # important: do not call syslog() from the SIGCHLD handler
++# # child_handler().   otherwise we can get into a loop if syslog()
++# # forks a process -- as it does in syslog-ng apparently! (bug 3625)
++# $Mail::SpamAssassin::Logger::LOG_SA{INHIBIT_LOGGING_IN_SIGCHLD_HANDLER} = 1;
++
+   my $eval_stat;
+   eval {
+     syslog($level, "%s", $msg); 1;
+   } or do {
+     $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+   };
+-  $Mail::SpamAssassin::Logger::LOG_SA{INHIBIT_LOGGING_IN_SIGCHLD_HANDLER} = 0;
++
++# no longer needed since a patch to bug 6745:
++# $Mail::SpamAssassin::Logger::LOG_SA{INHIBIT_LOGGING_IN_SIGCHLD_HANDLER} = 0;
+ 
+   if (defined $eval_stat) {
+     if ($self->check_syslog_sigpipe($msg)) {
+--- spamd/spamd.raw	2012/05/14 16:28:23	1338277
++++ spamd/spamd.raw	2012/05/14 16:31:09	1338278
+@@ -589,6 +589,7 @@
+ my $timeout_child;        # processing timeout (headers->finish), 0=no timeout
+ my $clients_per_child;    # number of clients each child should process
+ my %children;             # current children
++my @children_exited;
+ 
+ if ( defined $opt{'max-children'} ) {
+   $childlimit = $opt{'max-children'};
+@@ -1033,6 +1034,8 @@
+ # child_handler()  if !$scaling || am_running_on_windows();
+   child_handler();  # it doesn't hurt to call child_handler unconditionally
+ 
++  child_cleaner();
++
+   do_sighup_restart()  if defined $got_sighup;
+ 
+   for (my $i = keys %children; $i < $childlimit; $i++) {
+@@ -2523,7 +2526,8 @@
+   my ($sig) = @_;
+ 
+   # do NOT call syslog here unless the child's pid is in our list of known
+-  # children.  This is due to syslog-ng brokenness -- bugs 3625, 4237.
++  # children.  This is due to syslog-ng brokenness -- bugs 3625, 4237;
++  # see also bug 6745.
+ 
+   # clean up any children which have exited
+   for (;;) {
+@@ -2534,12 +2538,23 @@
+     #
+     my $pid = waitpid(-1, WNOHANG);
+     last if !$pid || $pid == -1;
+-    my $child_stat = $?;
++    push(@children_exited, [$pid, $?, $sig, time]);
++  }
+ 
+-    if (!defined $children{$pid}) {
+-      # ignore this child; we didn't realise we'd forked it. bug 4237
+-      next;
+-    }
++  $SIG{CHLD} = \&child_handler;    # reset as necessary, should be at end
++}
++
++# takes care of dead children, as noted by a child_handler()
++# called in a main program flow (not from a signal handler)
++#
++sub child_cleaner {
++  while (@children_exited) {
++    my $tuple = shift(@children_exited);
++    next if !$tuple;  # just in case
++    my($pid, $child_stat, $sig, $timestamp) = @$tuple;
++
++    # ignore this child if we didn't realise we'd forked it. bug 4237
++    next if !defined $children{$pid};
+ 
+     # remove them from our child listing
+     delete $children{$pid};
+@@ -2550,15 +2565,10 @@
+       my $sock = $backchannel->get_socket_for_child($pid);
+       if ($sock) { $sock->close(); }
+     }
+-
+-    unless ($Mail::SpamAssassin::Logger::LOG_SA{INHIBIT_LOGGING_IN_SIGCHLD_HANDLER}) {
+-      info("spamd: handled cleanup of child pid [%s]%s: %s",
+-           $pid, (defined $sig ? " due to SIG$sig" : ""),
+-           exit_status_str($child_stat,0));
+-    }
++    info("spamd: handled cleanup of child pid [%s]%s: %s",
++         $pid, (defined $sig ? " due to SIG$sig" : ""),
++         exit_status_str($child_stat,0));
+   }
+-
+-  $SIG{CHLD} = \&child_handler;    # reset as necessary, should be at end
+ }
+ 
+ sub restart_handler {
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 9 Andrej Zverev freebsd_committer freebsd_triage 2013-09-03 16:08:56 UTC
State Changed
From-To: open->closed

Committed. Thanks!