Bug #68709 [Opn->Fbk]: Segfault when parent::offsetGet() is called
| From: | laruence@php.net | Date: | Sat, 10 Jan 2015 16:17:45 +0000 |
| Subject: | Bug #68709 [Opn->Fbk]: Segfault when parent::offsetGet() is called | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189865@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68709&edit=1
ID: 68709
Updated by: laruence@php.net
Reported by: zecho23 at gmail dot com
Summary: Segfault when parent::offsetGet() is called
-Status: Open
+Status: Feedback
Type: Bug
Package: Reproducible crash
Operating System: Debian 8
PHP Version: 5.6.4
Block user comment: N
Private report: N
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
Previous Comments:
------------------------------------------------------------------------
[2015-01-01 12:38:52] zecho23 at gmail dot com
Description:
------------
I had some old code running for years (since PHP 5.3.x). After upgrade it started to segfault in a
overwritten offsetGet method in a class implementing ArrayAccess. After debugging it I reached the
broken code at following function made long ago:
public function offsetGet($key)
{
if (in_array($key, array_keys($this->_structure), true) && !isset($this[$key]))
{
return null;
}
return (parent::offsetExists($key)) ? parent::offsetGet($key) : null;
}
The result at dbg:
Program received signal SIGSEGV, Segmentation fault.
zend_call_method (object_pp=object_pp@entry=0x7fffff7ff078, obj_ce=0x1d14658,
fn_proxy=fn_proxy@entry=0x1d5beb0,
function_name=function_name@entry=0xb2598c "offsetGet",
function_name_len=function_name_len@entry=9,
retval_ptr_ptr=retval_ptr_ptr@entry=0x7fffff7ff088, param_count=1, arg1=0x2059d28, arg2=0x0)
at /build/php5-NIujy4/php5-5.6.4+dfsg/Zend/zend_interfaces.c:47
47 in /build/php5-NIujy4/php5-5.6.4+dfsg/Zend/zend_interfaces.c
I made it work after changing the last tine to:
return (parent::offsetExists($key)) ? $this->_structure[$key] : null;
Hope that helps.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68709&edit=1