Bug 186819 - [patch] perl-5.18 fixes for mail/p5-Mail-SpamAssassin
Summary: [patch] perl-5.18 fixes for mail/p5-Mail-SpamAssassin
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: freebsd-perl (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-16 16:20 UTC by Adam Weinberger
Modified: 2014-03-03 18:30 UTC (History)
0 users

See Also:


Attachments
patch-spamassassin-perl5.18 (4.76 KB, text/plain)
2014-02-16 16:20 UTC, Adam Weinberger
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Weinberger freebsd_committer freebsd_triage 2014-02-16 16:20:00 UTC
With the changes to hash ordering in perl 5.18, SpamAssassin throws multiple warnings on every
invocation:

	Use of each() on hash after insertion without resetting hash iterator results in undefined behavior, \
	Perl interpreter: 0x2880d800 at /usr/local/lib/perl5/site_perl/5.18/Mail/SpamAssassin/AsyncLoop.pm line 363, <GEN84> line 98.

There is a fix for this in SpamAssassin SVN, but they seem in no particular rush to release
SA 3.4. Bug #6937 (https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6937) has a patch
to backport these changes to 3.3.2 (https://issues.apache.org/SpamAssassin/attachment.cgi?id=5143&action=diff).

Fix: This patch adds bug #6937's patch. I've been trying it out locally and it does seem
to fix the problem.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2014-02-16 16:20:11 UTC
Responsible Changed
From-To: freebsd-ports-bugs->perl

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 adamw 2014-03-03 17:24:13 UTC
Guys any response on this? I'm sure you're hard at work on the 3.4.0 
update, but in the meantime it'd be really nice to have proper perl-5.18 
support here.

http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/186819

I'm going to commit this later today unless I hear otherwise from the 
team.

# Adam


--
Adam Weinberger
adamw@adamw.org
http://www.adamw.org
Comment 3 dfilter service freebsd_committer freebsd_triage 2014-03-03 18:19:24 UTC
Author: adamw
Date: Mon Mar  3 18:19:16 2014
New Revision: 346947
URL: http://svnweb.freebsd.org/changeset/ports/346947
QAT: https://qat.redports.org/buildarchive/r346947/

Log:
  Add a patch from SpamAssassin bug #6937 to improve compatibility
  with perl 5.18's changes to "each" ordering. This fixes the message:
  
  Use of each() on hash after insertion without resetting hash iterator results in undefined behavior, Perl interpreter: 0x2880d800 at /usr/local/lib/perl5/site_perl/5.18/Mail/SpamAssassin/AsyncLoop.pm line 363, <GEN84> line 98.
  
  PR:		ports/186819
  Approved by:	perl (maintainers)

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

Modified: head/japanese/p5-Mail-SpamAssassin/Makefile
==============================================================================
--- head/japanese/p5-Mail-SpamAssassin/Makefile	Mon Mar  3 18:03:24 2014	(r346946)
+++ head/japanese/p5-Mail-SpamAssassin/Makefile	Mon Mar  3 18:19:16 2014	(r346947)
@@ -1,7 +1,7 @@
 # Created by: TAOKA Fumiyoshi
 # $FreeBSD$
 
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	japanese mail perl5
 PKGNAMEPREFIX=	ja-p5-
 

Modified: head/mail/p5-Mail-SpamAssassin-Alt/Makefile
==============================================================================
--- head/mail/p5-Mail-SpamAssassin-Alt/Makefile	Mon Mar  3 18:03:24 2014	(r346946)
+++ head/mail/p5-Mail-SpamAssassin-Alt/Makefile	Mon Mar  3 18:19:16 2014	(r346947)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-PORTREVISION=	1
+PORTREVISION=	2
 PKGNAMESUFFIX=	-Alt
 
 MAINTAINER=	ports@FreeBSD.org

Modified: head/mail/p5-Mail-SpamAssassin/Makefile
==============================================================================
--- head/mail/p5-Mail-SpamAssassin/Makefile	Mon Mar  3 18:03:24 2014	(r346946)
+++ head/mail/p5-Mail-SpamAssassin/Makefile	Mon Mar  3 18:19:16 2014	(r346947)
@@ -3,7 +3,7 @@
 
 PORTNAME=	Mail-SpamAssassin
 PORTVERSION=	3.3.2
-PORTREVISION?=	8		# committer: please bump PORTREVISION on Slaves
+PORTREVISION?=	9		# committer: please bump PORTREVISION on Slaves
 CATEGORIES?=	mail perl5
 MASTER_SITES=	${MASTER_SITE_APACHE:S/$/:apache/} ${MASTER_SITE_PERL_CPAN:S/$/:cpan/}
 MASTER_SITE_SUBDIR=	spamassassin/source/:apache Mail/:cpan

Added: head/mail/p5-Mail-SpamAssassin/files/patch-bug6937
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/mail/p5-Mail-SpamAssassin/files/patch-bug6937	Mon Mar  3 18:19:16 2014	(r346947)
@@ -0,0 +1,97 @@
+--- lib/Mail/SpamAssassin/AsyncLoop.pm.orig	2011-06-07 01:59:17.000000000 +0200
++++ lib/Mail/SpamAssassin/AsyncLoop.pm	2013-05-29 01:37:58.000000000 +0200
+@@ -361,5 +361,12 @@ 
+     $now = time;  # capture new timestamp, after possible sleep in 'select'
+ 
+-    while (my($key,$ent) = each %$pending) {
++    # A callback routine may generate another DNS query, which may insert
++    # an entry into the %$pending hash thus invalidating the each() context.
++    # So, make sure that callbacks are not called while the each() context
++    # is open, or avoid using each().  [Bug 6937]
++    #
++  # while (my($key,$ent) = each %$pending) {
++    foreach my $key (keys %$pending) {
++      my $ent = $pending->{$key};
+       my $id = $ent->{id};
+       if (defined $ent->{poll_callback}) {  # call a "poll_callback" if exists
+@@ -449,5 +456,6 @@ 
+   my $foundcnt = 0;
+   my $now = time;
+-  while (my($key,$ent) = each %$pending) {
++  foreach my $key (keys %$pending) {
++    my $ent = $pending->{$key};
+     dbg("async: aborting after %.3f s, %s: %s",
+         $now - $ent->{start_time},
+--- lib/Mail/SpamAssassin/Conf/Parser.pm.orig	2011-06-07 01:59:17.000000000 +0200
++++ lib/Mail/SpamAssassin/Conf/Parser.pm	2013-05-29 01:32:06.000000000 +0200
+@@ -1249,5 +1249,5 @@ 
+   my $mods = '';
+   local ($1,$2);
+-  if ($re =~ s/^m{//) {
++  if ($re =~ s/^m\{//) {
+     $re =~ s/}([a-z]*)$//; $mods = $1;
+   }
+--- lib/Mail/SpamAssassin/DnsResolver.pm.orig	2011-06-07 01:59:17.000000000 +0200
++++ lib/Mail/SpamAssassin/DnsResolver.pm	2013-05-29 01:32:06.000000000 +0200
+@@ -441,8 +441,14 @@ 
+       if (!defined($timeout) || $timeout > 0)
+         { $timer = $self->{main}->time_method("poll_dns_idle") }
++      $! = 0;
+       ($nfound, $timeleft) = select($rout=$rin, undef, undef, $timeout);
+     }
+     if (!defined $nfound || $nfound < 0) {
+-      warn "dns: select failed: $!";
++      if ($!) { warn "dns: select failed: $!\n" }
++      else    { info("dns: select interrupted") }
++      return;
++    } elsif (!$nfound) {
++      if (!defined $timeout) { warn("dns: select returned empty-handed\n") }
++      elsif ($timeout > 0) { dbg("dns: select timed out %.3f s", $timeout) }
+       return;
+     }
+--- lib/Mail/SpamAssassin/Message.pm.orig	2011-06-07 01:59:17.000000000 +0200
++++ lib/Mail/SpamAssassin/Message.pm	2013-05-29 01:32:06.000000000 +0200
+@@ -567,5 +567,5 @@ 
+     # bug 5557: windows requires tmp file be closed before it can be rm'd
+     if (ref $part->{'raw'} eq 'GLOB') {
+-      close($part->{'raw'})  or die "error closing input file: $!";
++      close($part->{'raw'})  or warn "error closing input file: $!";
+     }
+ 
+--- lib/Mail/SpamAssassin/PerMsgStatus.pm.orig	2011-06-07 01:59:17.000000000 +0200
++++ lib/Mail/SpamAssassin/PerMsgStatus.pm	2013-05-29 01:32:06.000000000 +0200
+@@ -421,6 +421,6 @@ 
+     }
+ 
+-    # ignore tests with 0 score in this scoreset
+-    next if ($scores->{$test} == 0);
++    # ignore tests with 0 score (or undefined) in this scoreset
++    next if !$scores->{$test};
+ 
+     # Go ahead and add points to the proper locations
+@@ -1253,11 +1253,10 @@ 
+               my $line = '';
+               foreach my $test (sort @{$self->{test_names_hit}}) {
+-                if (!$line) {
+-                  $line .= $test . "=" . $self->{conf}->{scores}->{$test};
+-                } else {
+-                  $line .= $arg . $test . "=" . $self->{conf}->{scores}->{$test};
+-                }
++                my $score = $self->{conf}->{scores}->{$test};
++                $score = '0'  if !defined $score;
++                $line .= $arg  if $line ne '';
++                $line .= $test . "=" . $score;
+               }
+-              $line ? $line : 'none';
++              $line ne '' ? $line : 'none';
+             },
+ 
+--- lib/Mail/SpamAssassin/Util.pm.orig	2013-05-29 01:29:59.000000000 +0200
++++ lib/Mail/SpamAssassin/Util.pm	2013-05-29 01:33:16.000000000 +0200
+@@ -1588,5 +1588,5 @@ 
+     return undef;   # invalid
+   }
+-  elsif ($re =~ s/^m{//) {              # m{foo/bar}
++  elsif ($re =~ s/^m\{//) {             # m{foo/bar}
+     $delim = '}';
+   }
_______________________________________________
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 4 Adam Weinberger freebsd_committer freebsd_triage 2014-03-03 18:19:32 UTC
State Changed
From-To: open->closed

Thanks for the approval, guys. I've committed this change (and bumped 
the other SpamAssassin ports). Let me know if there were any other 
dependent ports that I forgot to bump. 

I'll take a whack at that SA 3.4.0 PR.