-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix #63914 #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #63914 #250
Conversation
Could you elaborate on what this patch is trying to do? |
There's more information here https://bugs.php.net/bug.php?id=63914 and here http://bugs.xdebug.org/view.php?id=897. The setup for the bug looks something like this: <?php
class PHPUnit_Util_ErrorHandler
{
public static function handleError($errno, $errstr, $errfile, $errline)
{
throw new Exception;
}
}
set_error_handler(
array('PHPUnit_Util_ErrorHandler', 'handleError'),
E_ALL | E_STRICT
);
$dom = new DOMDocument;
$dom->saveXML('foo'); When In fact, in the case that you're using an extension that hooks into The best way to follow this is to set up the gdb sessions from https://bugs.php.net/bug.php?id=63914 and step through the execution to see what's happening. This patch intends to check for an exception after |
Alright, that’s above my head :) |
A little more context: This bug is very closely related to https://bugs.php.net/bug.php?id=45805 which was fixed here: 1ff61ab. The bug exists in the following section: https://github.com/php/php-src/blob/642721b3/Zend/zend_vm_def.h#L1997-L2013. My patch adds a check to handle the uncaught exception originating from This patch can be backported to PHP 5.4 (you'll need to update the Maybe @derickr or @sebastianbergmann can take a look at this if they get a minute :) |
Bump :) |
Goes a bit over my head as well! Maybe @dstogov knows? |
Patch looks good to me. At least it makes sense that if an exception is thrown during argument type verification the function should not be run. Only thing you might want to do is shift the order of the code around so you only initialize the retval if there is no exception (so you don't have to alloc+dtor it when one is thrown): if (fbc->common.arg_info) {
zend_uint i=0;
zval **p = (zval**)EX(function_state).arguments;
ulong arg_count = opline->extended_value;
while (arg_count>0) {
zend_verify_arg_type(fbc, ++i, *(p-arg_count), 0 TSRMLS_CC);
arg_count--;
}
}
if (EXPECTED(EG(exception) == NULL)) {
temp_variable *ret = &EX_T(opline->result.var);
MAKE_STD_ZVAL(ret->var.ptr);
ZVAL_NULL(ret->var.ptr);
ret->var.ptr_ptr = &ret->var.ptr;
ret->var.fcall_returned_reference = (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0;
if (!zend_execute_internal) {
/* saves one function call if zend_execute_internal is not used */
fbc->internal_function.handler(opline->extended_value, ret->var.ptr, (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) ? &ret->var.ptr : NULL, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC);
} else {
zend_execute_internal(execute_data, NULL, RETURN_VALUE_USED(opline) TSRMLS_CC);
}
if (!RETURN_VALUE_USED(opline)) {
zval_ptr_dtor(&ret->var.ptr);
}
} |
Handle exceptions from the `zend_verify_arg_type` check in `zend_do_fcall_common_helper_SPEC` appropriately.
Good point, @nikic. I've updated the fix to reflect your suggestions. |
Looks like @dstogov added this at git.php.net. Thanks :) |
Handle exceptions from the
zend_verify_arg_type
check inzend_do_fcall_common_helper_SPEC
appropriately.Unfortunately, I can't think of a way to test this 😞