php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41209 Segmentation fault with ArrayAccess, set_error_handler and undefined var
Submitted: 2007-04-27 07:23 UTC Modified: 2007-04-28 08:54 UTC
From: christian dot kaps at imaxx21 dot com Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5.2.1 OS: Ubuntu 7.04 Server
Private report: No CVE-ID: None
 [2007-04-27 07:23 UTC] christian dot kaps at imaxx21 dot com
Description:
------------
I get the message 'child pid 13149 exit signal Segmentation fault (11)' in my apache logs. The problem occurs when i use the following code.



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

class env
{
	public function __construct()
	{
		set_error_handler(array(__CLASS__, 'errorHandler'));
	}
	
	public static function errorHandler($errno, $errstr, $errfile, $errline)
	{
		throw new ErrorException($errstr, 0, $errno, $errfile, $errline); 
	}
}

class cache implements ArrayAccess
{
	private $container = array();
	
	public function offsetGet($id) {}
	
	public function offsetSet($id, $value) {}
	
	public function offsetUnset($id) {}
	
	public function offsetExists($id)
	{
		return isset($this->containers[(string) $id]);
	}
}

$env = new env();
$cache = new cache();
var_dump(isset($cache[$id]));

?>

Expected result:
----------------
Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: id' 

Actual result:
--------------
child pid 13149 exit signal Segmentation fault (11) in error.log

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-27 07:33 UTC] johannes@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

I can\'t reproduce it.
Please add a gdb backtrace in case you can reproduce it.
 [2007-04-28 08:50 UTC] christian dot kaps at imaxx21 dot com
I have it tested on my gentoo box at home and the error doesn`t occour. It is probably a ubuntu problem!?

Next time when is submit a bug I will first try it at home (o;
 [2007-04-28 08:54 UTC] tony2001@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.

I've fixed an invalid read in CVS, so you should not be able to reproduce it with the snapshots.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 12:01:31 2024 UTC