Bug #74164 [NEW]: PHP hangs when an invalid value is dynamically passed to typehinted by-ref arg.
| From: | shiranai7 at hotmail dot com | Date: | Sat, 25 Feb 2017 02:28:07 +0000 |
| Subject: | Bug #74164 [NEW]: PHP hangs when an invalid value is dynamically passed to typehinted by-ref arg. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-207544@lists.php.net to get a copy of this message | ||
From: shiranai7 at hotmail dot com
Operating system: Windows, Linux
PHP version: 7.1.2
Package: Scripting Engine problem
Bug Type: Bug
Bug description:PHP hangs when an invalid value is dynamically passed to typehinted by-ref arg.
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 bug report at https://bugs.php.net/bug.php?id=74164&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74164&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74164&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74164&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74164&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74164&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74164&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74164&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74164&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74164&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74164&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74164&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74164&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74164&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74164&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74164&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74164&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74164&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74164&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74164&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74164&r=mysqlcfg