recover from a segfault

From: Date: Tue, 21 Feb 2006 23:00:47 +0000
Subject: recover from a segfault
Groups: php.internals 
Request: Send a blank email to internals+get-21978@lists.php.net to get a copy of this message
Hi, In the last days I've exchanged some e-mails with PCRE's author because of one more bug that appeared in our database about segfaults in PCRE (related to stack overflows). PCRE can consume a lot of stack, because of backtracking (thus segfaulting PHP). Yesterday I've discovered that when using the setrlimit() function, most segfaults can be avoided (http://mega.ist.utl.pt/~ncpl/php_pcre_stack_limits.txt) :) But I was thinking why we can't fail more silently from segfaults. A recursive PHP function can easily segfault PHP. Why can't we catch the signal and recover from the error? (and print a "stack overflow" message, like java does). I've done a little program for fun to show myself how to catch the SIGSEGV signals and print a nice message. (http://mega.ist.utl.pt/~ncpl/break-stack.html) So, catching the signal is easy. What about recovery? Doesn't anyone has experience in this area? Can this be done? (and in most SAPIs/architectures?) Nuno P.S.: sorry if my "bright" idea is dumb and/or undoable :)

« previous php.internals (#21978) next »