Bug 3456 - Error in unixlocker awl stat[3] variable not defined.
Summary: Error in unixlocker awl stat[3] variable not defined.
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamassassin (show other bugs)
Version: 2.63
Hardware: PC Linux
: P5 minor
Target Milestone: Future
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
: 3458 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-06-02 10:52 UTC by Lucas Albers
Modified: 2006-12-06 08:43 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status
patch for undefined lock comparison for stat[3] patch None Lucas Albers [NoCLA]
patch for undefined lock comparison for stat[3] patch None Lucas Albers [NoCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Lucas Albers 2004-06-02 10:52:53 UTC
Result:
Outputs error message about unable to lock awl file, and then error message 
about how it is unable to unlock the file.

Repro:
Debian 2.63-1
local.cf:
bayes_learn_to_journal 1
bayes_journal_max_size 5120000 

bayes_auto_learn_threshold_nonspam   0.4
bayes_auto_learn_threshold_spam 12

Fix:
It appears in the file UnixLocker.pm that the stat[3] array is not defined 
correctly in some situations, and does not handle situations in which it is not 
defined.
Attached is my attempt at a unified diff to troubleshoot the problem.
If stat[3] is not defined, then assume that lockfile was not created.
As you well realize, I'm must checking to make sure stat[3] is defined before 
comparing against it. 
This patch solves the problem as perl spews out an error message that stat[3] 
is not defined which can then generates a temporary delivery error, depending 
on what mta+sa combo you are using.

versus 2.63
--- UnixLocker.pm.original      Wed Jun  2 11:43:51 2004
+++ UnixLocker.pm       Wed Jun  2 11:44:49 2004
@@ -66,6 +66,11 @@
     }
     # link _may_ return false even if the link _is_ created
     @stat = stat($lock_tmp);
+    if (!defined ($stat[3])){
+    dbg ("lock: $$ link to lock not defined");
+    $is_locked=0;
+    last;
+    }
     if ($stat[3] > 1) {
       dbg("lock: $$ link to $lock_file: stat ok");
       $is_locked = 1;
Comment 1 Daniel Quinlan 2004-06-02 11:01:08 UTC
Subject: Re:  New: Error in unixlocker awl stat[3] variable not defined.

> Outputs error message about unable to lock awl file, and then error message 
> about how it is unable to unlock the file.

What's the exact error message?  Also, which version of Perl are you
using?

Maybe we should review the Locker/UnixNFSSafe.pm code ... again.

As far as a patch goes, can you submit a patch against our SVN tree?
The license has changed, so we need you to submit a patch against the
3.0 tree.

Comment 2 Lucas Albers 2004-06-02 11:03:49 UTC
*** Bug 3458 has been marked as a duplicate of this bug. ***
Comment 3 Lucas Albers 2004-06-09 13:19:38 UTC
Created attachment 2019 [details]
patch for undefined lock comparison for stat[3]
Comment 4 Lucas Albers 2004-06-09 13:20:31 UTC
Created attachment 2020 [details]
patch for undefined lock comparison for stat[3]
Comment 5 Lucas Albers 2004-06-09 13:22:08 UTC
Trivial fix. If variable stat[3] is not defined assume the lock was not created.
Currently it just pukes.
Patch attached for 2.63 and 3.0.
Comment 6 Malte S. Stretz 2004-06-09 13:35:41 UTC
That patch is too trivial :) Though the idea behind it is correct. Will attach 
a cleaner one in a few minutes... 
Comment 7 Theo Van Dinter 2004-06-09 13:40:43 UTC
This code was redone a bit for 3.0, the patch as attached won't even apply.

Is this still an issue w/ 3.0?  I don't see how the stat would fail as coded now.
Comment 8 Malte S. Stretz 2004-06-09 14:19:59 UTC
wow. that code is such a mess... 
Comment 9 Malte S. Stretz 2004-06-09 16:02:45 UTC
I actually need a bit more time. Tomorrow is another day... 
Comment 10 Daniel Quinlan 2005-03-30 01:09:09 UTC
move bug to Future milestone (previously set to Future -- I hope)
Comment 11 Justin Mason 2006-12-06 08:43:21 UTC
applied an alternative fix in r483140; it is more appropriate to retry again in
that situation.