# Spamassassin problem since upgrading Perl



## xy16644 (Nov 17, 2013)

I have just finished upgrading my Perl from 5.16.3 to 5.18.1. After upgrading I ran `portmaster -r perl`. All was looking good until I had a look in my /var/log/maillog. I am getting the following errors:


```
Nov 17 16:50:12 alpha spamd[49019]: Use of each() on hash after insertion without resetting hash iterator results in undefined behavior at /usr/local/lib/perl5/site_perl/5.18/Mail/SpamAssassin/AsyncLoop.pm line 363.
Nov 17 16:50:12 alpha spamd[49019]: Use of each() on hash after insertion without resetting hash iterator results in undefined behavior at /usr/local/lib/perl5/site_perl/5.18/Mail/SpamAssassin/AsyncLoop.pm line 363.
Nov 17 16:50:12 alpha spamd[49019]: Use of each() on hash after insertion without resetting hash iterator results in undefined behavior at /usr/local/lib/perl5/site_perl/5.18/Mail/SpamAssassin/AsyncLoop.pm line 363.
Nov 17 16:50:12 alpha spamd[49019]: plugin: eval failed: bayes: (in learn) locker: safe_lock: cannot create tmp lockfile /var/spool/spamd/.spamassassin/bayes.lock.alpha.bsdpanic.com.49019 for /var/spool/spamd/.spamassassin/bayes.lock: No such file or directory
```

I had a look online and found this: 3.3.2 and Perl 5.18.0: Altering hash requires restarting loop else UNDEFINED... and Revision 1487178

I've had a read through them but am still unsure how to proceed. How do I apply Spamassassin patches? Why am I getting an error saying spamd can't create a temporary lockfile? Has anyone else experienced this and fixed it?

Thanks!


----------



## cpm@ (Nov 17, 2013)

Do the following: 

First, download the patch and rename it without the filename extension as patch-bug6937, then place it at the /usr/ports/mail/p5-Mail-SpamAssassin/files directory.

Finally, just run `portmaster mail/p5-Mail-SpamAssassin`


----------



## xy16644 (Nov 18, 2013)

Thanks for the reply!

In the end (before reading your post) I checked out the latest trunk version of Spamassassin, overwrote /usr/local/lib/perl5/site_perl/5.18/Mail/SpamAssassin/AsyncLoop.pm with the new file and restarted Spamassassin.

All looks good so far with no more of the errors I reported in the first post.


----------



## xy16644 (Jan 19, 2014)

*Re:*



			
				cpm said:
			
		

> Do the following:
> 
> First, download the patch and rename it without the filename extension as patch-bug6937, then place it at the /usr/ports/mail/p5-Mail-SpamAssassin/files directory.
> 
> Finally, just run `portmaster mail/p5-Mail-SpamAssassin`



I'm having this issue again but this time on my newly built server. I have Perl 5.18.2 installed and SpamAssasin 3.3.2_8. I downloaded patch-bug6937 and copied into /usr/ports/mail/p5-Mail-SpamAssassin/files. But when I run `portmaster mail/p5-Mail-SpamAssassin` it says:


```
File to patch:
```

and when I enter:


```
/usr/ports/mail/p5-Mail-SpamAssassin/files/patch-bug6937
```

it says:

```
File to patch: /usr/ports/mail/p5-Mail-SpamAssassin/files/patch-bug6937
2 out of 2 hunks failed--saving rejects to /usr/ports/mail/p5-Mail-SpamAssassin/files/patch-bug6937.rej
```

What am I doing wrong?


----------



## cpm@ (Jan 19, 2014)

Here you have the patch fixed (replacing the previous patch).

P.S. Follow the instructions of the second post.


----------



## xy16644 (Jan 19, 2014)

I know there's a patch but I am battling to install it?

I've also tried downloading the files from http://svn.apache.org/viewvc?view=revision&revision=1487178 and overwriting the files I have but then Spamassassin won't start when I restart the service.

Help please  :q


----------



## xy16644 (Jan 19, 2014)

I did follow the instructions in the second post. Hence my post, they didn't work. It wouldn't install the patch.


----------



## cpm@ (Jan 19, 2014)

I tested the above patch and it's applied cleanly. 

```
# cd /usr/ports/mail/p5-Mail-SpamAssassin && make patch
===>  License APACHE20 accepted by the user
===>  Found saved configuration for p5-Mail-SpamAssassin-3.3.2_8
===> Fetching all distfiles required by p5-Mail-SpamAssassin-3.3.2_8 for building
===>  Extracting for p5-Mail-SpamAssassin-3.3.2_8
=> SHA256 Checksum OK for Mail-SpamAssassin-3.3.2.tar.gz.
===>  Patching for p5-Mail-SpamAssassin-3.3.2_8
===>  Applying FreeBSD patches for p5-Mail-SpamAssassin-3.3.2_8
/usr/bin/sed -i.bak -e '/Razor2/s/^#loadplugin/loadplugin/' /usr/ports/mail/p5-Mail-SpamAssassin/work/Mail-SpamAssassin-3.3.2/rules/v312.pre
/usr/bin/sed -i.bak -e '/SPF/s/^loadplugin/#loadplugin/' /usr/ports/mail/p5-Mail-SpamAssassin/work/Mail-SpamAssassin-3.3.2/rules/init.pre
```
Anyway, show the error output.


----------



## xy16644 (Jan 19, 2014)

I explained the error I was getting in post 4. All the details there as to what I did and the error I got.


----------



## xy16644 (Jan 19, 2014)

Heres the error:


```
(/usr/ports/mail/p5-Mail-SpamAssassin)$ sudo make patch
===>  Patching for p5-Mail-SpamAssassin-3.3.2_8
===>  Applying FreeBSD patches for p5-Mail-SpamAssassin-3.3.2_8
Ignoring previously applied (or reversed) patch.
4 out of 4 hunks ignored--saving rejects to lib/Mail/SpamAssassin/BayesStore/MySQL.pm.rej
=> Patch patch-bug6624 failed to apply cleanly.
*** [do-patch] Error code 1

Stop in /usr/ports/mail/p5-Mail-SpamAssassin.
*** [patch] Error code 1

Stop in /usr/ports/mail/p5-Mail-SpamAssassin.
```
 
I copied patch-bug6937 into the /usr/ports/mail/p5-Mail-SpamAssassin/files directory before running the above.


----------



## cpm@ (Jan 19, 2014)

Run `# make clean` before run `# make patch`

P.S. You can download it here.


----------



## xy16644 (Jan 19, 2014)

Ok, ran `make clean`, downloaded the latest patch and then ran `make patch` but it still failed. 

I'm still getting the following error:


```
(/usr/ports/mail/p5-Mail-SpamAssassin)$ sudo make patch
===>  License APACHE20 accepted by the user
===>  Found saved configuration for p5-Mail-SpamAssassin-3.3.2_8
===> Fetching all distfiles required by p5-Mail-SpamAssassin-3.3.2_8 for building
===>  Extracting for p5-Mail-SpamAssassin-3.3.2_8
=> SHA256 Checksum OK for Mail-SpamAssassin-3.3.2.tar.gz.
===>  Patching for p5-Mail-SpamAssassin-3.3.2_8
===>  Applying FreeBSD patches for p5-Mail-SpamAssassin-3.3.2_8
2 out of 2 hunks failed--saving rejects to lib/Mail/SpamAssassin/AsyncLoop.pm.rej
1 out of 1 hunks failed--saving rejects to lib/Mail/SpamAssassin/Conf/Parser.pm.rej
patch: **** malformed patch at line 65:
=> Patch patch-bug6937 failed to apply cleanly.
=> Patch(es) patch-bug6624 patch-bug6655 patch-bug6698 patch-bug6745 applied cleanly.
*** [do-patch] Error code 1

Stop in /usr/ports/mail/p5-Mail-SpamAssassin.
*** [patch] Error code 1

Stop in /usr/ports/mail/p5-Mail-SpamAssassin.
```

The other patches seem to install fine but not 6937 for some reason?


----------



## cpm@ (Jan 19, 2014)

Oops, I just see the problem, please, remove all the ^M characters of the file.

```
% tr -d \\r < patch-bug6937.txt > patch-bug6937
```


----------



## xy16644 (Jan 20, 2014)

Yeah, that did the trick. Thanks so much for your help!


----------

