develooper Front page | perl.perl5.porters | Postings from January 2005

Re: [perl #33945] Segmentation fault with deep recursion in regex engine

Thread Previous | Thread Next
Dave Mitchell
January 29, 2005 10:11
Re: [perl #33945] Segmentation fault with deep recursion in regex engine
Message ID:
On Sat, Jan 29, 2005 at 05:18:59PM +0100, A. Pagaltzis wrote:
> * Dave Mitchell via RT <> [2005-01-29 16:40]:
> > I can't really see what else Perl can do. The segfault happens
> > when Perl extends the stack too far. This can't be avoided.
> Isn't it possible to check before extending the stack whether
> there's room for the planned extension?

No. we're talking about the processor stack here, not the Perl stack. That
would imply that every function call that perl ever makes (and in any
libraries that is uses) must check first, which would grind things to a
halt. Also, I don't believe there is a portable way of determining the
current stack allocation.

> > The SIGSEGV could be caught, but then there's nothing sensible
> > that perl could then do to retrieve the situation.
> As I said I don't think there is much that perl could do to
> salvage the running program; but if possible it should at least
> throw an error along the lines of "Deep recursion in regex in
> file line 42" and, ideally, proceed to die in an orderly
> manner (global destruction and all that).

No, because by the time of a SIGSEGV, perl can't execute any code that
might call a function, because it hasn't got a stack.

Thank God I'm an atheist.....

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About