php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74102 Dump print_r buffer on out of memory error
Submitted: 2017-02-15 13:36 UTC Modified: 2017-07-05 08:25 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: daniel at krol dot me Assigned:
Status: Duplicate Package: Output Control
PHP Version: 7.0.15 OS: OSX, Ubuntu
Private report: No CVE-ID: None
 [2017-02-15 13:36 UTC] daniel at krol dot me
Description:
------------
Tested on 

7.0.15(Ubuntu), 

OSX
PHP 7.0.6 (cli) (built: Apr 29 2016 04:21:39) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

and

OSX
PHP 5.6.21 (cli) (built: Apr 29 2016 02:31:44)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

all provide similiar result

Might be related to 
https://bugs.php.net/bug.php?id=54114

Test script:
---------------
<?php
ini_set("memory_limit", "2m");

$v = array_fill(0,1024*5/2/4/2/8, "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");

while (true) {
	$v[] = print_r($v, true);
}

Expected result:
----------------
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 581632 bytes) in /private/tmp/test.php on line 7

Call Stack:
    0.0003     355824   1. {main}() /private/tmp/test.php:0
    0.0012     948768   2. print_r() /private/tmp/test.php:7

Actual result:
--------------
...
...
    [29] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
    [30] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
    [31] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
    [32] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
    [33] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
    [34] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
    [35] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
    [36] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
    [37] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
    [38] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
    [39] => 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
)

)

)

)

)

)

    [46] =>
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 581632 bytes) in /private/tmp/test.php on line 7

Call Stack:
    0.0003     355824   1. {main}() /private/tmp/test.php:0
    0.0012     948768   2. print_r() /private/tmp/test.php:7

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-05 06:45 UTC] rmoisto at gmail dot com
This is security issue as it exposes variables to the end user that were supposed to be private.
 [2017-07-05 08:25 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2017-07-05 08:25 UTC] nikic@php.net
Duplicate of bug #67467, which has been fixed in PHP 7.2
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Aug 24 18:01:27 2019 UTC