php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68709 Segfault when parent::offsetGet() is called
Submitted: 2015-01-01 12:38 UTC Modified: 2015-01-18 04:22 UTC
From: zecho23 at gmail dot com Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 5.6.4 OS: Debian 8
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zecho23 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-01-01 12:38 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-10 16:17 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2015-01-10 16:17 UTC] laruence@php.net
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.


 [2015-01-18 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC