Bug #74164 [Opn->Csd]: PHP hangs when an invalid value is dynamically passed to typehinted by-ref arg.
| From: | laruence@php.net | Date: | Sat, 25 Feb 2017 04:01:08 +0000 |
| Subject: | Bug #74164 [Opn->Csd]: PHP hangs when an invalid value is dynamically passed to typehinted by-ref arg. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207545@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74164&edit=1
ID: 74164
Updated by: laruence@php.net
Reported by: shiranai7 at hotmail dot com
Summary: PHP hangs when an invalid value is dynamically
passed to typehinted by-ref arg.
-Status: Open
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Windows, Linux
PHP Version: 7.1.2
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=36fcc4cb5d92dabc8c8f6f0587c81093bcac878c
Log: Fixed bug #74164 (PHP hangs when an invalid value is dynamically passed to typehinted by-ref
arg)
Previous Comments:
------------------------------------------------------------------------
[2017-02-25 02:28:00] shiranai7 at hotmail dot com
Description:
------------
Dynamically passing an invalid value to a typehinted function argument which is also passed by
reference while a custom exception-throwing error handler is active will cause PHP to hang.
Interesting observations:
- doesn't happen in PHP versions prior to 7.1.0
- removing the namespace prevents the bug from happening
- the error handler must throw an exception for the hang to occur
- the call must be dynamic or a fatal error is produced instead
- the kind of typehint doesn't seem to matter (it happens with array, a class, a scalar
typehint etc.)
Test script:
---------------
<?php
namespace Foo;
set_error_handler(function () {
throw new \Exception();
});
call_user_func(function (array &$ref) {}, 'not_an_array_variable');
Expected result:
----------------
Fatal error: Uncaught Exception in script.php on line 6
Exception: in script.php on line 6
Call Stack:
0.0010 412712 1. {main}() script.php:0
0.0010 413352 2. call_user_func:{script.php:9}() script.php:9
0.0010 416144 3. Foo\{closure}() script.php:9
Actual result:
--------------
The script doesn't terminate. PHP hangs indefinitely.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74164&edit=1