Bug #73896 [Asn->Csd]: spl_autoload() crashes when calls magic _call()
| From: | dmitry@php.net | Date: | Mon, 09 Jan 2017 12:14:36 +0000 |
| Subject: | Bug #73896 [Asn->Csd]: spl_autoload() crashes when calls magic _call() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206445@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73896&edit=1
ID: 73896
Updated by: dmitry@php.net
Reported by: dmitry@php.net
Summary: spl_autoload() crashes when calls magic _call()
-Status: Assigned
+Status: Closed
Type: Bug
Package: SPL related
Operating System: *
PHP Version: 7.0Git-2017-01-09 (Git)
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4f1b24d97447434973a06bdc70fc1670de17bd80
Log: Fixed bug #73896 (spl_autoload() crashes when calls magic _call())
Previous Comments:
------------------------------------------------------------------------
[2017-01-09 12:04:59] dmitry@php.net
Description:
------------
The following script crashes on second attempt to call spl_autoload(), because the first attempt
destroyed trampoline function.
Test script:
---------------
<?php
class Registrator {
public static function call($callable, array $args) {
return call_user_func_array($callable, [$args]);
}
}
class teLoader {
public function __construct() {
Registrator::call('spl_autoload_register', [$this, 'autoload']);
}
public function __call($method, $args) {
$this->doSomething();
}
protected function autoload($class) {
die("Protected autoload() called!\n");
}
public function doSomething() {
throw new teException();
}
}
$teLoader = new teLoader();
try {
new teChild();
} catch (Throwable $e) {
echo "Exception: ", $e->getMessage() , "\n";
}
?>
Expected result:
----------------
Exception: Class 'teException' not found
Actual result:
--------------
==4663== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==4663== Access not within mapped region at address 0x5
==4663== at 0x866E114: ZEND_CALL_TRAMPOLINE_SPEC_HANDLER (zend_vm_execute.h:1974)
==4663== by 0x866A63A: execute_ex (zend_vm_execute.h:429)
==4663== by 0x860C079: zend_call_function (zend_execute_API.c:828)
==4663== by 0x863DD4B: zend_call_method (zend_interfaces.c:101)
==4663== by 0x8462C20: zif_spl_autoload_call (php_spl.c:408)
==4663== by 0x860C10E: zend_call_function (zend_execute_API.c:842)
==4663== by 0x860C611: zend_lookup_class_ex (zend_execute_API.c:1001)
==4663== by 0x860CF62: zend_fetch_class_by_name (zend_execute_API.c:1436)
==4663== by 0x866FF76: ZEND_NEW_SPEC_CONST_HANDLER (zend_vm_execute.h:3193)
==4663== by 0x866A63A: execute_ex (zend_vm_execute.h:429)
==4663== by 0x860C079: zend_call_function (zend_execute_API.c:828)
==4663== by 0x863DD4B: zend_call_method (zend_interfaces.c:101)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73896&edit=1