From 3b60b03b142006a122410f58b92484e601354d1d Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Tue, 24 Jan 2023 01:45:05 +0900 Subject: [PATCH 1/8] DEBUG: do not suppress arginfo / zpp mismatch via ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH --- Zend/tests/arginfo_zpp_mismatch.inc | 1 + Zend/tests/arginfo_zpp_mismatch_suppress.phpt | 12 ++++++++++++ Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt | 12 ++++++++++++ Zend/zend.c | 5 +++++ Zend/zend_execute.c | 4 ++++ Zend/zend_globals.h | 4 ++++ ext/zend_test/test.c | 13 +++++++++++++ 7 files changed, 51 insertions(+) create mode 100644 Zend/tests/arginfo_zpp_mismatch_suppress.phpt create mode 100644 Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt diff --git a/Zend/tests/arginfo_zpp_mismatch.inc b/Zend/tests/arginfo_zpp_mismatch.inc index 221c347aaa915..57bc23949204e 100644 --- a/Zend/tests/arginfo_zpp_mismatch.inc +++ b/Zend/tests/arginfo_zpp_mismatch.inc @@ -10,6 +10,7 @@ function skipFunction($function): bool { || $function === 'zend_create_unterminated_string' || $function === 'zend_test_array_return' || $function === 'zend_leak_bytes' + || $function === 'zend_test_arginfo_zpp_mismatch' /* mess with output */ || (is_string($function) && str_starts_with($function, 'ob_')) || $function === 'output_add_rewrite_var' diff --git a/Zend/tests/arginfo_zpp_mismatch_suppress.phpt b/Zend/tests/arginfo_zpp_mismatch_suppress.phpt new file mode 100644 index 0000000000000..fefc1aa0ec16a --- /dev/null +++ b/Zend/tests/arginfo_zpp_mismatch_suppress.phpt @@ -0,0 +1,12 @@ +--TEST-- +Test suppressing arginfo / zpp mismatch +--EXTENSIONS-- +zend_test +--ENV-- +ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=1 +--FILE-- +internal_function.handler == ZEND_FN(pass) || (fbc->internal_function.fn_flags & ZEND_ACC_FAKE_CLOSURE)) { /* Be lenient about the special pass function and about fake closures. */ return 0; diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 17469fab0c11e..957ad61c29437 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -271,6 +271,10 @@ struct _zend_executor_globals { zend_string *filename_override; zend_long lineno_override; +#ifdef ZEND_DEBUG + bool suppress_arginfo_zpp_mismatch; +#endif + void *reserved[ZEND_MAX_RESERVED_RESOURCES]; }; diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index 96898d2d71f1c..f89828af89308 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -335,8 +335,21 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_iterable_legacy, 0, 1, IS_I ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arg2, IS_ITERABLE, 1, "null") ZEND_END_ARG_INFO() +static ZEND_FUNCTION(zend_test_arginfo_zpp_mismatch) +{ + zend_long foo; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(foo); + ZEND_PARSE_PARAMETERS_END(); +} + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_arginfo_zpp_mismatch, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() + static const zend_function_entry ext_function_legacy[] = { ZEND_FE(zend_iterable_legacy, arginfo_zend_iterable_legacy) + ZEND_FE(zend_test_arginfo_zpp_mismatch, arginfo_zend_test_arginfo_zpp_mismatch) ZEND_FE_END }; From a1575458432511c6fc7e7c6fa40dfcd4af115511 Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Tue, 24 Jan 2023 10:37:58 +0900 Subject: [PATCH 2/8] DEBUG: fix SKIPIF --- Zend/tests/arginfo_zpp_mismatch_suppress.phpt | 2 ++ Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Zend/tests/arginfo_zpp_mismatch_suppress.phpt b/Zend/tests/arginfo_zpp_mismatch_suppress.phpt index fefc1aa0ec16a..392cd4c215e5b 100644 --- a/Zend/tests/arginfo_zpp_mismatch_suppress.phpt +++ b/Zend/tests/arginfo_zpp_mismatch_suppress.phpt @@ -2,6 +2,8 @@ Test suppressing arginfo / zpp mismatch --EXTENSIONS-- zend_test +--SKIPIF-- + --ENV-- ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=1 --FILE-- diff --git a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt index 1d4bef8559dbf..d5f5c907629f1 100644 --- a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt +++ b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt @@ -2,6 +2,8 @@ Test don't suppress arginfo / zpp mismatch --EXTENSIONS-- zend_test +--SKIPIF-- + --ENV-- ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=0 --FILE-- From 18f01f828a8b5eb406367931a06cd04f5550518c Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Wed, 25 Jan 2023 11:34:03 +0900 Subject: [PATCH 3/8] without env --- Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt index d5f5c907629f1..b5cda3d4d762c 100644 --- a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt +++ b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt @@ -4,8 +4,6 @@ Test don't suppress arginfo / zpp mismatch zend_test --SKIPIF-- ---ENV-- -ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=0 --FILE-- Date: Wed, 25 Jan 2023 16:52:36 +0900 Subject: [PATCH 4/8] skipif opcache --- Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt index b5cda3d4d762c..146ee88abc38b 100644 --- a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt +++ b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt @@ -3,7 +3,9 @@ Test don't suppress arginfo / zpp mismatch --EXTENSIONS-- zend_test --SKIPIF-- - + +--ENV-- +ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=0 --FILE-- Date: Wed, 25 Jan 2023 19:22:54 +0900 Subject: [PATCH 5/8] fix skipif opcache && jit=function --- Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt index 146ee88abc38b..d92d037493b07 100644 --- a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt +++ b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt @@ -3,7 +3,7 @@ Test don't suppress arginfo / zpp mismatch --EXTENSIONS-- zend_test --SKIPIF-- - + --ENV-- ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=0 --FILE-- From 4409adbf027d4e11cc4c4f0d4607570fb3d7743f Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Wed, 25 Jan 2023 22:40:22 +0900 Subject: [PATCH 6/8] fix jit unsupported platform --- Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt index d92d037493b07..a4624279efe02 100644 --- a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt +++ b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt @@ -3,7 +3,7 @@ Test don't suppress arginfo / zpp mismatch --EXTENSIONS-- zend_test --SKIPIF-- - + --ENV-- ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=0 --FILE-- From e836fee83d998adbe2fa89198cdaa99d20e78f87 Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Thu, 26 Jan 2023 10:28:50 +0900 Subject: [PATCH 7/8] fix: test: opcache sometime skip arginfo / zpp check --- Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt index a4624279efe02..67d1be88b5e75 100644 --- a/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt +++ b/Zend/tests/arginfo_zpp_mismatch_unsuppress.phpt @@ -3,7 +3,7 @@ Test don't suppress arginfo / zpp mismatch --EXTENSIONS-- zend_test --SKIPIF-- - + --ENV-- ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=0 --FILE-- From 4bddb69df0d01d063725d73b86fb56bb3e832875 Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Thu, 26 Jan 2023 10:32:51 +0900 Subject: [PATCH 8/8] update NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index b1abfcaf440f0..0d98044331285 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ PHP NEWS . Fixed incorrect check condition in ZEND_YIELD. (nielsdos) . Fixed incorrect check condition in type inference. (nielsdos) . Fix incorrect check in zend_internal_call_should_throw(). (nielsdos) + . arginfo / zpp validation can now be skipped on debug build with + ZEND_SUPPRESS_ARGINFO_ZPP_MISMATCH=1 (zeriyoshi) - FFI: . Fixed incorrect bitshifting and masking in ffi bitfield. (nielsdos)