Bug #78397 [NEW]: Issue with variable pass
| From: | jeremy at derusse dot com | Date: | Sat, 10 Aug 2019 18:01:56 +0000 |
| Subject: | Bug #78397 [NEW]: Issue with variable pass | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222171@lists.php.net to get a copy of this message | ||
From: jeremy at derusse dot com
Operating system: Linux
PHP version: 7.2.21
Package: Arrays related
Bug Type: Bug
Bug description:Issue with variable pass
Description:
------------
We faced a segfault issue in Symfony test suite resumed to a simple
empty PHPUnit script.
https://github.com/sebastianbergmann/phpunit/issues/3790
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: https://3v4l.org/6AASB
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
https://3v4l.org/MFjQI
the method getData which returns the recursive reference array is also
useless, but, same as before, when I don't call it, everything work =>
https://3v4l.org/Q73bL
Test script:
---------------
<?php
function getData()
{
$a[0] = &$a;
return $a;
}
function recurcive(&$data)
{
array_slice($data, 0);
$data[] = 'X';
if (end($data[0]) !== 'X') {
recurcive($data[0]);
}
}
$data = getData();
recurcive($data);
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.
--
Edit bug report at https://bugs.php.net/bug.php?id=78397&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78397&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78397&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78397&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78397&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78397&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78397&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78397&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78397&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78397&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78397&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78397&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78397&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78397&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78397&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78397&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78397&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78397&r=mysqlcfg