php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31185 Crash when exceptions thrown from ArrayAccess::offsetUnset()
Submitted: 2004-12-19 16:56 UTC Modified: 2005-03-19 19:53 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: Jason at AMP-design dot net Assigned: helly (profile)
Status: Closed Package: SPL related
PHP Version: 5.0.3 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Jason at AMP-design dot net
New email:
PHP Version: OS:

 

 [2004-12-19 16:56 UTC] Jason at AMP-design dot net
Description:
------------
This crashes both on PHP 5.0.3 on Windows 2003 / Apache 2.0.52 and Centos 3 (Redhat Entperise Linux 3 for cheapskates) with Apache 2.0.48 and PHP 5.0.2

This occurs due to the Exception thrown. Removing the exception will prevent the crash.

Reproduce code:
---------------
<?php

header('Content-type: text/plain');
class FooBar implements ArrayAccess {
	private $array = array();

	public function offsetExists($index) {
		return isset($this->array[$index]);
	}

	public function offsetGet($index) {
		return $this->array[$index];
	}

	public function offsetSet($index, $value) {
		$this->array[$index] = $value;
	}

	public function offsetUnset($index) {
		throw new Exception('Just try and make me crash ya sucker ;-)');
		unset($this->array[$index]);
	}

}

$i = 0;
$foo = new FooBar();
$foo[$i] = $i++;
$foo[$i] = $i++;
$foo[$i] = $i++;
unset($foo[1]);

print_R($foo);
?>

Expected result:
----------------
$foo would dump out it's array elements which should be 0 and 2

Actual result:
--------------
Apache crash (exists with Parent: child process exited with status 3221225477 -- Restarting on Windows Apache 2 log, dunno about Linux, can't be faffed to mess about in SSH, however I do not get a HTTP reponse, and therefore I assume it segfaults)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-11 16:41 UTC] Jason at amp-design dot net
Just to let you know this bug also occurs when you throw exceptions from other internal SPL methods. For instance, if an exception is thrown in Iterator::current() PHP will crash.

Interestingly enough, when I ran this on the command line version of PHP (under Mac OS), where the Exception is thrown, it echos "Bus error" on to the console. I have no idea what a "bus" has to do with this, but it might help you track the problem.

I guess it would be worth checking other methods in the SPL for this bug seeing as it occurs in various interfaces that bind into core parts of the Zend engine.
 [2005-03-19 19:53 UTC] helly@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC