Skip to content

Commit ce41a3d

Browse files
committed
DEBUG: do not suppress arginfo / zpp mismatch via ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH
1 parent 972c74c commit ce41a3d

7 files changed

+51
-0
lines changed

Zend/tests/arginfo_zpp_mismatch.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function skipFunction($function): bool {
1010
|| $function === 'zend_create_unterminated_string'
1111
|| $function === 'zend_test_array_return'
1212
|| $function === 'zend_leak_bytes'
13+
|| $function === 'zend_test_arginfo_zpp_mismatch'
1314
/* mess with output */
1415
|| (is_string($function) && str_starts_with($function, 'ob_'))
1516
|| $function === 'output_add_rewrite_var'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Test suppressing arginfo / zpp mismatch
3+
--EXTENSIONS--
4+
zend_test
5+
--ENV--
6+
ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=1
7+
--FILE--
8+
<?php
9+
zend_test_arginfo_zpp_mismatch(1);
10+
echo 'success';
11+
--EXPECT--
12+
success
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Test don't suppress arginfo / zpp mismatch
3+
--EXTENSIONS--
4+
zend_test
5+
--ENV--
6+
ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=0
7+
--FILE--
8+
<?php
9+
zend_test_arginfo_zpp_mismatch(1);
10+
echo 'success';
11+
--EXPECTF--
12+
Fatal error: Arginfo / zpp mismatch during call of zend_test_arginfo_zpp_mismatch() in %s on line %d

Zend/zend.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,11 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
10081008
tsrm_set_new_thread_end_handler(zend_new_thread_end_handler);
10091009
tsrm_set_shutdown_handler(zend_interned_strings_dtor);
10101010
#endif
1011+
1012+
#ifdef ZEND_DEBUG
1013+
char *tmp = getenv("ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH");
1014+
EG(suppress_arginfo_zpp_mismatch) = tmp && ZEND_ATOL(tmp);
1015+
#endif
10111016
}
10121017
/* }}} */
10131018

Zend/zend_execute.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,10 @@ static zend_never_inline ZEND_ATTRIBUTE_UNUSED bool zend_verify_internal_arg_typ
12101210
* trust that arginfo matches what is enforced by zend_parse_parameters. */
12111211
ZEND_API bool zend_internal_call_should_throw(zend_function *fbc, zend_execute_data *call)
12121212
{
1213+
if (EG(suppress_arginfo_zpp_mismatch)) {
1214+
return 0;
1215+
}
1216+
12131217
if (fbc->internal_function.handler == ZEND_FN(pass) || (fbc->internal_function.fn_flags & ZEND_ACC_FAKE_CLOSURE)) {
12141218
/* Be lenient about the special pass function and about fake closures. */
12151219
return 0;

Zend/zend_globals.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ struct _zend_executor_globals {
271271
zend_string *filename_override;
272272
zend_long lineno_override;
273273

274+
#ifdef ZEND_DEBUG
275+
bool suppress_arginfo_zpp_mismatch;
276+
#endif
277+
274278
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
275279
};
276280

ext/zend_test/test.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,21 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_iterable_legacy, 0, 1, IS_I
335335
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arg2, IS_ITERABLE, 1, "null")
336336
ZEND_END_ARG_INFO()
337337

338+
static ZEND_FUNCTION(zend_test_arginfo_zpp_mismatch)
339+
{
340+
zend_long foo;
341+
342+
ZEND_PARSE_PARAMETERS_START(1, 1)
343+
Z_PARAM_LONG(foo);
344+
ZEND_PARSE_PARAMETERS_END();
345+
}
346+
347+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_arginfo_zpp_mismatch, 0, 0, IS_VOID, 0)
348+
ZEND_END_ARG_INFO()
349+
338350
static const zend_function_entry ext_function_legacy[] = {
339351
ZEND_FE(zend_iterable_legacy, arginfo_zend_iterable_legacy)
352+
ZEND_FE(zend_test_arginfo_zpp_mismatch, arginfo_zend_test_arginfo_zpp_mismatch)
340353
ZEND_FE_END
341354
};
342355

0 commit comments

Comments
 (0)