php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24812 Calling exit() from a destructor breaks next executed script
Submitted: 2003-07-25 17:21 UTC Modified: 2003-07-27 08:48 UTC
From: vma1 at abv dot bg Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-07-25 (dev) OS: Slackware Linux 9.0
Private report: No CVE-ID: None
 [2003-07-25 17:21 UTC] vma1 at abv dot bg
Description:
------------
When a destructor runs and you call exit() from within it, this will break the next executed PHP script with a "Cannot redeclare..." message. The bug appears when the script is run on a web server, not from the command line. I think that the HTTP request must be 1.1 not 1.0, because for me it appears only when HTTP request has keepalive connection enabled. To reproduce the bug, place the following script on a web server and run it from the web browser (in my case it was Internet Explorer 6.0)

Reproduce code:
---------------
<?
class someclass
{
	public function __destruct ()
	{
		exit ("Here we terminate");
	}
}

header ("Location: http://" . $_SERVER ["SERVER_NAME"] . $_SERVER ["SCRIPT_NAME"]);
$obj = new someclass;

function evil ()
{
}
?>

Expected result:
----------------
No output is expected. The HTTP request should loop in redirection calls.

Actual result:
--------------
Fatal error: Cannot redeclare evil() (previously declared in :15) in /usr/local/apache/site/htdocs/bug.php on line 15


Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-27 08:48 UTC] stas@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Aug 18 20:01:29 2024 UTC