|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68059 array_shift segfaults
Submitted: 2014-09-19 21:42 UTC Modified: 2017-10-24 08:25 UTC
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:0 (0.0%)
From: rrh at newrelic dot com Assigned:
Status: Suspended Package: xhprof (PECL)
PHP Version: 5.6.0 OS: ubuntu 14.04
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.
Bug Type:
From: rrh at newrelic dot com
New email:
PHP Version: OS:


 [2014-09-19 21:42 UTC] rrh at newrelic dot com
If xhprof is enabled, and the php 5.6 executes php function array_shift, then the guts of _phpi_pop indirects through 0 for the return_value_ptr, resulting in a segfault.

The xhprof call through ->handler passes a 3rd argument which is the result of evaluating the C code:
  (EX(function_state).function->common.fn_flags &  ZEND_ACC_RETURN_REFERENCE) ?  &retvar->var.ptr:NULL
and for the case of the array_shift function, this passes NULL as the value of return_value_ptr in the environment of array_shift.

For PHP 5.6, and apparently PHP 5.6 only, the implementation of array_shift calls _phpi_pop which invokes macro RETVAL_ZVAL_FAST which has a code path that stores through return_value_ptr, without doing any checking for null pointers.

There are a handful of uses of RETVAL_ZVAL_FAST in PHP 5.6, all(?) related to array manipulation or iteration.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-24 08:25 UTC]
-Status: Open +Status: Suspended
 [2017-10-24 08:25 UTC]
This package has not had a release for over 4 years, and the last bit of git activity was over 2 years ago, so I think its safe to say this extension is no longer in active development. If development picks back up, then please re-open this report
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Feb 29 16:01:38 2024 UTC