|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78397 Memory exhausted on custom recursion detection in phpunit
Submitted: 2019-08-10 18:01 UTC Modified: 2019-08-16 11:10 UTC
From: jeremy at derusse dot com Assigned:
Status: Verified Package: Arrays related
PHP Version: 7.2.21 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-08-10 18:01 UTC] jeremy at derusse dot com
We faced a segfault issue in Symfony test suite resumed to a simple empty PHPUnit script.

after investigation, I found that PHPUnit detect circular reference in arrays by putting a marker in the array, and check in the recurcion if the data have the marker => if yes it's a circular reference. 

This issue: in PHP 7.2 the reference is lost somehow and the recurcion is not detected which cause either a segfault or a memory limit exeeded.

I tried to resume this issue to the simplest script possible (bellow).

output here:

Few comments:

`array_slice` is totally useless in my code, but when I don't call it, everything work. Maybe it's the originator of the issue => see

the method `getData` which returns the recursive reference array is also useless, but, same as before, when I don't call it, everything work =>

Test script:

function getData()
    $a[0] = &$a;

    return $a;

function recurcive(&$data)
    array_slice($data, 0);
    $data[] = 'X';
    if (end($data[0]) !== 'X') {

$data = getData();

Expected result:
no ouput

Actual result:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20480 bytes) in /in/cDZmm on line 5

Process exited with code 255.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-08-16 11:10 UTC]
-Summary: Issue with variable pass +Summary: Memory exhausted on custom recursion detection in phpunit -Status: Open +Status: Verified
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Aug 20 13:01:27 2019 UTC