swatch v3.1.1 causes a segmentation fault when invoked
in the check mode, i.e. it does not seg fault when
invoked with --version or --dump-script. The program
appears to function normally, however, and will process
the indicated log file. Some simple tests revealed
that the cuprits are these sections of code in the
function doit(), right after the FORK:
foreach my $k (sort keys %SIG) {
dprint(8, "doit(): a: $k => $SIG{$k}") if
defined $SIG{$k};
}
and
foreach my $k (sort keys %SIG) {
dprint(8, "doit(): b: $k => $SIG{$k}") if
defined $SIG{$k};
}
Commenting out the dprint line eliminated the seg
fault. More specifically, removing the $SIG{$k} solved
the problem. That is, a line such as this:
dprint(8, "doit(): a: $k => ");
caused no problems. Note the removal of both accesses
to $SIG{$k}, once in the drpint call and once in the if
test.
Logged In: YES
user_id=305442
System:
Linux 2.4.20 SMP (2 processors)
gcc v3.2.1
glibc v3.2.1
Perl v5.8.0
swatch v3.1.1
Mdoules:
Carp::Clan v5.3
Date::Calc v5.4
File::Tail v0.99.1
Time:HiRes v1.68
TimeDate v1.16
Date::Manip v5.42a
Logged In: YES
user_id=305442
Further testing revealed that the key RTMIN was the culprit.
Changing the code thus:
- dprint(8, "doit(): a: $k => $SIG{$k}") if
defined $SIG{$k};
+ if ($k ne 'RTMIN') {
+ dprint(8, "doit(): a: $k => $SIG{$k}") if
defined $SIG{$k};
+ }
and
- dprint(8, "doit(): b: $k => $SIG{$k}") if
defined $SIG{$k};
+ if ($k ne 'RTMIN') {
+ dprint(8, "doit(): b: $k => $SIG{$k}") if
defined $SIG{$k};
+ }
produced a working swatch program.