Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12037 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25955 invoked by uid 1010); 9 Aug 2004 11:43:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 25929 invoked from network); 9 Aug 2004 11:43:52 -0000 Received: from unknown (HELO server.stewartmc.co.uk) (207.218.248.16) by pb1.pair.com with SMTP; 9 Aug 2004 11:43:52 -0000 Received: from adsl-221-60-174.rmo.bellsouth.net ([68.221.60.174] helo=[192.168.2.4]) by server.stewartmc.co.uk with asmtp (Exim 4.34) id 1Bu8ZC-0004Uz-Qb; Mon, 09 Aug 2004 12:43:51 +0100 Message-ID: <41176375.3020400@php.net> Date: Mon, 09 Aug 2004 07:43:49 -0400 User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Marcus Boerger CC: internals@lists.php.net References: <20040808141747.23849.qmail@pb1.pair.com> <1815162431.20040809072810@marcus-boerger.de> In-Reply-To: <1815162431.20040809072810@marcus-boerger.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-MailScanner-Information: Please contact the ISP for more information X-MailScanner: Found to be clean X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.stewartmc.co.uk X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - php.net X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] Destructors will not be called after an exception is caught? From: nforbes@php.net (Noel Forbes) Hey Marcus, Although your script did work, it appears that the exception doesn't even need to be thrown in the destructor of a class, but rather anywhere as long as there is a destructor in any instantiated class. Here's a code snippet: public function create($host, $port, $protocol = 'tcp', $timeout = 30) { $connString = '' . $protocol . '://' . $host . ':' . $port . ''; $conn = @stream_socket_client($connString, $connErrorNumber, $connErrorString, $timeout); if(!$conn) { throw new ConnectionException($connErrorString, ConnectionException::E_CONNECT); } $controller = Controller::getInstance(); $controller->setAttribute('conn', $conn); } And the destructor causing the error: public function __destruct() { $controller = Controller::getInstance(); $controller->removeAttribute('connObject'); } Note that these are in two different classes altogether. I'm trying the latest 5.1.0 snap now, let's hope it works! ;) Noel Marcus Boerger wrote: >Hello Noel, > >i suppose one of your destructors did throw an exception. But you didn't >get any output from it. Try either 5.0.0-dev or 5.1.0-dev where the >shutdown order wasaddressed again. A reproducing script would be this: > >php -r 'class t{function __destruct(){throw new exception(__METHOD__);}}$o=new t;' > >regards >marcus > >Sunday, August 8, 2004, 4:17:47 PM, you wrote: > > > >>Hello all, >> >> > > > >>You'll have to excuse my ignorance if something like this has already >>been posted. >> >> > > > >>In my process of writing complicated-for-the-sake-of-complicated scripts >>(:D), I came across a very strange error: >> >> > > > >>Fatal error: Exception thrown without a stack frame in Unknown on line 0 >> >> > > > >>What was happening was that an Exception was being thrown in a class, >>which in turn was caught by this (in psuedo-code): >> >> > > > >>try { >> load_classes(); >>} >>catch (Exception $e) { >> echo $e; >>} >> >> > > > >>After the exception was caught and had been successfully printed to the >>screen, the above fatal error occured. The cause of this error was a >>__destruct() method in another class. Since the catch had killed the >>script, the destructor was not able to execute, as far as I can tell. >> >> > > > >>I've confirmed this on PHP 5.0.0 on FreeBSD and PHP 5.0.0 RC3 on Win32. >>Is this error message appropriate? Should this even be happening at all? >> >> > > > >>Any replies are welcomed. >> >> > > > >>Regards, >>Noel Forbes >> >> > > > > > >