On Wed, Nov 27, 2002 at 08:04:45PM -0800, Konstantin 'Kastus' Shchuka wrote:
> A rather weird problem:
>
> It's mon-0.99.2 on SuSE 8.1, perl 5.8.0 (compiled with gcc 3.2
> if it is relevant)
>
> monshow segfaults when there is a failed watch with a long output
> (~40 lines, in my particular case foundry-chassis.monitor).
>
> kastus@bursa:~> /usr/sbin/monshow
> Segmentation fault
>
> If the output from failed watches is not long, monshow runs fine.
Further research showed that the problem is with Text::ParseWords.
This is the minimal test case which triggers the bug:
#!/usr/bin/perl
use Text::ParseWords;
$o = q{'} . q{1} x 3527 . q{'} ;
print "Source string: $o\n";
$l = length $o;
print "string is $l bytes long\n";
@words = parse_line('\s+', 0, $o);
$i = 0;
foreach (@words) {
print "$i: <$_>\n";
$i++;
}
Segfault occurs in the following regexp in Text::ParseWords :
$line =~ m/^(["']) # a $quote
((?:\\.|(?!\1)[^\\])*) # and $quoted text
\1 # followed by the same quote
([\000-\377]*) # and the rest
| # --OR--
^((?:\\.|[^\\"'])*?) # an $unquoted text
(\Z(?!\n)|(?-x:$delimiter)|(?!^)(?=["']))
# plus EOL, delimiter, or quote
([\000-\377]*) # the rest
/x; # extended layout
The same code works in perl 5.6.1 without any problems.
--
Konstantin 'Kastus' Shchuka
Unix System Administrator
ePocrates Inc.
tel 650.227.1786
fax 650.592.6995
_______________________________________________
mon mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/mon