Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21978 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91380 invoked by uid 1010); 21 Feb 2006 23:00:55 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 91365 invoked from network); 21 Feb 2006 23:00:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Feb 2006 23:00:55 -0000 X-Host-Fingerprint: 212.55.154.24 relay4.ptmail.sapo.pt Linux 2.4/2.6 Received: from ([212.55.154.24:59481] helo=sapo.pt) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 78/B5-45151-1AB9BF34 for ; Tue, 21 Feb 2006 18:00:49 -0500 Received: (qmail 11205 invoked by uid 0); 21 Feb 2006 23:00:45 -0000 Received: from unknown (HELO sapo.pt) (10.134.35.152) by relay4 with SMTP; 21 Feb 2006 23:00:45 -0000 Received: (qmail 32131 invoked from network); 21 Feb 2006 23:00:44 -0000 X-AntiVirus: PTMail-AV 0.3.88 X-Virus-Status: Clean (0.00584 seconds) Received: from unknown (HELO pc07653) (nunoplopes@sapo.pt@[81.193.185.155]) (envelope-sender ) by mta2 (qmail-ldap-1.03) with SMTP for ; 21 Feb 2006 23:00:44 -0000 Message-ID: <005101c6373a$a6ef0170$0100a8c0@pc07653> To: "PHPdev" Date: Tue, 21 Feb 2006 23:00:47 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 Subject: recover from a segfault From: nlopess@php.net ("Nuno Lopes") 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 :)