#31185 [Opn->Ver]: Crash when exceptions thrown from ArrayAccess::offsetUnset()

From: Date: Mon, 10 Jan 2005 22:22:34 +0000
Subject: #31185 [Opn->Ver]: Crash when exceptions thrown from ArrayAccess::offsetUnset()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-71786@lists.php.net to get a copy of this message
 ID:               31185
 Updated by:       tony2001@php.net
 Reported By:      Jason at AMP-design dot net
-Status:           Open
+Status:           Verified
-Bug Type:         Reproducible crash
+Bug Type:         SPL related
-Operating System: Windows 2003 / CentOS 3
+Operating System: *
-PHP Version:      5.0.3
+PHP Version:      5CVS-2005-01-10


Previous Comments:
------------------------------------------------------------------------

[2004-12-19 16:56:06] 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)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31185&edit=1


Thread (4 messages)

« previous php.bugs (#71786) next »