https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8561

            Bug ID: 8561
           Summary: Timeout.pm can leave an alarm pending with no handler,
                    which kills the spamd parent on DragonFly
           Product: Spamassassin
           Version: 4.0.2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Libraries
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: Undefined

Created attachment 6277
  --> https://bz.apache.org/SpamAssassin/attachment.cgi?id=6277&action=edit
Timeout.pm: leave no alarm pending where no handler catches it

The failure that led to this has only been observed in spamd stress testing on
DragonFly BSD, but I'm treating it as a robustness fix for rarely occurring
circumstances on other platforms.

On DragonFly BSD, the spamd parent process can die under load with nothing
logged. spamc then passes mail through unscanned until spamd is restarted.

The cause is in Mail::SpamAssassin::Timeout. On DragonFly 6.4, alarm() can
report a pending timer of up to a second just after a fork, when no timer is
set. The end result of the current code is that the parent then dies at the
first idle second.

Looking at that code, I found a second way an alarm can reach the wrong
handler, or none, when there is more than a second delay, such as can be caused
by a stalled host. Effects include:

- a process with no SIGALRM handler, such as sa-learn or the spamassassin
script, is killed
- in a spamd child, the --timeout-child handler runs at that point. Its die
bypasses Timeout.pm's cleanup, so later timed code in that child times out
after a second.

The attached patch changes Timeout.pm in two places. An alarm that no Timeout
set counts as an outer timer only if $SIG{ALRM} has a handler. Otherwise
Timeout.pm uses its own timer and does not arm that alarm again. The block that
installs the timeout handler now holds an object whose DESTROY calls alarm(0),
so the timer is off before the caller's handler is restored. There is one
change in behaviour: an alarm that a caller set without a SIGALRM handler is
cancelled by the first Timeout instead of being armed again afterwards. Nothing
in SpamAssassin sets an alarm without a handler.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to