develooper Front page | perl.perl5.porters | Postings from December 2004

Re: Runaway process problems for hosting companies

Thread Previous | Thread Next
From:
jm
Date:
December 7, 2004 17:06
Subject:
Re: Runaway process problems for hosting companies
Message ID:
20041208010530.35F7E590103@radish.jmason.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Lyle Hopkins writes:
> On Thu, Nov 11, 2004 at 10:49:10AM -0800, Justin Mason wrote:
> 
> >FWIW, this'll work well on perl 5.6.x -- but perl 5.8.x cannot trap
> >signals inside a single OP if I recall correctly.  This means that an
> >out-of-control regexp match is unkillable.
> >
> >That is one bug we've run into in SpamAssassin a few times, and it'd be
> >nice to get back to perl 5.6.x behaviour -- or have that under script
> >control via a $^FOO var or similar.
> 
> Could you post some sample code that would recreate this problem so that I
> can do some testing?

hey -- been a while, but I finally got a tuit.  here goes:

  #!/usr/bin/perl -w

  use strict;
  my $text = (("o" x 9999) . "x") x 999;
  $SIG{ALRM} = \&got_alrm; alarm 2;
  print "entering re match\n";
  $text =~ /o*xo*y/;
  print "done re match\n";
  alarm 0; exit;

  sub got_alrm { print "got sigalrm successfully\n"; }


some samples:

$ PERL_SIGNALS=safe perl5.8.4 ~/ftp/bench/demo-evil-regexp
entering re match
[doesn't gets sigalrm inside the re match]
^C

$ PERL_SIGNALS=unsafe perl5.8.4 ~/ftp/bench/demo-evil-regexp
entering re match
got sigalrm successfully
[still carries on with the match, though]
^C

$ /usr/local/perl561/bin/perl ~/ftp/bench/demo-evil-regexp
entering re match
got sigalrm successfully
[still carries on with the match, though]
^C


this is, of course, something we can run into quite a lot in SpamAssassin,
especially when naive users write their own rules without knowing the
awful truth about the "*" metacharacter... ;)

also, worth noting that SIGINT gets through, as long as the default sig
handler is used; however, if $SIG{INT} is set to a perl handler fn, it
suffers the same fate as $SIG{ALRM} above, ie. only gets called in a
timely fashion in perls < 5.8.x or where $PERL_SIGNALS="unsafe".

it'd be nice if there was a way to interrupt the match, too, on a SIGALRM.
In all the "unsafe" cases above, the match still continues unabated
once the signal handler returns.

- --j.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Exmh CVS

iD8DBQFBtlNaMJF5cimLx9ARAjBPAKC3tlbMB4tGMGU1k8KBtU1mlVx1XwCfZxP+
e3xjaFCT55bLb8cJTk7J8kI=
=tP4r
-----END PGP SIGNATURE-----


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About