php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77387 Recursion detection broken when printing GLOBALS
Submitted: 2018-12-31 10:40 UTC Modified: 2018-12-31 14:53 UTC
From: sjon at hortensius dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.3.0 OS: archlinux
Private report: No CVE-ID: None
 [2018-12-31 10:40 UTC] sjon at hortensius dot net
Description:
------------
I found this while going through https://3v4l.org/bughunt/7.3.0/7.2.13+7.2.12. Previously when printing _GLOBALS - recursion was detected and prevented. This seems broken

Test script:
---------------
See https://3v4l.org/AdLgJ

print_r($GLOBALS);

Expected result:
----------------
Array ( ... ) [GLOBALS] => Array *RECURSION* )

Actual result:
--------------
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 31461376 bytes) in /in/AdLgJ on line 3

Process exited with code 255.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-31 14:53 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: *General Issues +Package: Scripting Engine problem
 [2018-12-31 14:53 UTC] cmb@php.net
> I found this while going through
> https://3v4l.org/bughunt/7.3.0/7.2.13+7.2.12.

Highly appreciated – thanks!

This bug is caused by refactoring the recursion protection[1].
The Z_REFCOUNTED_P() check[2] fails for $GLOBALS, so the recursion
protection is not applied.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=cb9d81ef4f07f82835273800b0cb3d6a67816050>
[2] <https://github.com/php/php-src/blob/php-7.3.0/Zend/zend.c#L427>
 [2019-01-01 14:14 UTC] sjon at hortensius dot net
Thanks! I've found another problem - very likely related:

https://3v4l.org/LUq3k

this segfaults, while previously recursion was properly detected
 [2019-01-02 08:47 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=54a58a73805991d3cec927a112965368211b03a5
Log: Fixed bug #77387 (Recursion detection broken when printing GLOBALS)
 [2019-01-02 08:47 UTC] laruence@php.net
-Status: Verified +Status: Closed
 [2019-01-02 08:47 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=384b02d058f2682757a9b03e2384d15bfddec6ac
Log: Fixed bug #77387 (Recursion detection broken when printing GLOBALS)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC