ID: 28934
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Closed
Bug Type: Zend Engine 2 problem
Operating System: Linux
PHP Version: 5.0.0RC3
New Comment:
Fixed in previous releases.
Previous Comments:
------------------------------------------------------------------------
[2004-09-28 18:26:23] phpbugs at d51 dot biz
This is still present in PHP 5.0.2. I've created a patch file. Just
save it as php-5.0.2/call_user_func_array.patch and run "patch -p0 <
call_user_func_array.patch" from within php-5.0.2/.
----- Begin Patch -----
diff -Naur ../php-5.0.2/ext/standard/basic_functions.c
./ext/standard/basic_functions.c
--- ../php-5.0.2/ext/standard/basic_functions.c 2004-08-19
10:15:32.000000000 -0500
+++ ./ext/standard/basic_functions.c 2004-09-24 13:48:58.000000000
-0500
@@ -1988,8 +1988,10 @@
current++;
}
- if (call_user_function_ex(EG(function_table), NULL, *func,
&retval_ptr, count, func_params, 0, NULL TSRMLS_CC) == SUC
CESS && retval_ptr) {
- COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+ if (call_user_function_ex(EG(function_table), NULL, *func,
&retval_ptr, count, func_params, 0, NULL TSRMLS_CC) == SUC
CESS ) {
+ if (retval_ptr) {
+ COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+ }
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to
call %s()", name);
}
----- End Patch -----
------------------------------------------------------------------------
[2004-09-13 17:19:48] fch at hexanet dot fr
Same problem with php 5.0.1.
Exception generated by call_user_func_array() was not catched, a
warning error was generated instead.
------------------------------------------------------------------------
[2004-09-13 16:50:18] phpbugs at d51 dot biz
--- NOTE ---
This was added to bug #29617 as I didn't realize it had been marked a
duplicate. I'm reposting it here in hopes that it gets picked up.
---
I've been running up against this blasted bug for some time in my test
scripts - can't test for Exceptions without hard coding it. Anyhow, I
just peeked under the hood and think I've got it squashed.
file: ./ext/standand/basic_functions.c line 1984 - 1985 reads:
if (call_user_function_ex(EG(function_table), NULL, *func,
&retval_ptr,
count, func_params, 0, NULL TSRMLS_CC) == SUCCESS && retval_ptr) {
COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
The cause of the bug seems to be the "&& retval_ptr" as an exception
doesn't appear to return the same. It works when you adjust it to work
like call_user_func() where it can succeed even if retval_ptr doesn't
exist and/or is false.
Modified ./ext/standand/basic_functions.c line 1984 - 1985 replaced to
1984 - 1984:
if (call_user_function_ex(EG(function_table), NULL, *func,
&retval_ptr,
count, func_params, 0, NULL TSRMLS_CC) == SUCCESS ) {
if (retval_ptr) {
COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
}
I compiled it and ran the test that Benjamin posted on the 16th of
Augest. I did get the correct output (11, 17, & 23).
The modified file is available from:
http://www.domain51productions.com/php/basic_functions.c
In the latest 5.0.X CVS, these lines have moved to 1991 - 1992.
Note: If there's another way to handle submitting a patch, just let me
know.
-Travis
------------------------------------------------------------------------
[2004-08-18 21:34:14] phpbugs at d51 dot biz
I ran the following to see if the exception was being thrown. It is
thrown and caught:
Reproduce code:
---------------
<?php
function foo()
{
throw new Exception('bar');
}
try {
call_user_func_array('foo', array());
} catch (Exception $e) {
echo $e->getMessage();
}
// Expected output: bar
?>
Actual result:
--------------
Warning: call_user_func_array() [function.call-user-func-array]: Unable
to call foo() in /path/to/test.php on line 16
bar
Extended Info:
--------------
I also attempted catching an exception with call_user_func() - it
worked as expected producing only "bar". I also produced an identical
outcome when I used a non-empty array as the second argument.
This is most definitely an issue with call_user_func_array(). The
following code produces a similar error:
Reproduce code:
---------------
<?php
assert_options( ASSERT_CALLBACK, 'throwException' );
function foo()
{
assert( false );
throw new Exception('bar');
}
function throwException( ) {
throw new Exception('assert');
}
try {
call_user_func_array('foo', array(0, 1));
} catch (Exception $e) {
echo $e->getMessage();
}
// Expected Output: assert
?>
Actual results:
---------------
Warning: assert() [function.assert]: Assertion failed in
/path/to/test.php on line 7
Warning: call_user_func_array() [function.call-user-func-array]: Unable
to call foo() in /path/to/test.php on line 20
assert
More Info:
----------
Bug #29617 seems to be a duplicate of this report.
------------------------------------------------------------------------
[2004-08-01 23:17:58] JustinHagstrom at yahoo dot com
This also happens when an exception is thrown in any callback
function.
It is present in the final release of PHP 5 and the snapshots from Aug
01, 2004.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/28934
--
Edit this bug report at http://bugs.php.net/?id=28934&edit=1