Skip to content

Add mode for verifying internal function param defaults #5366

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nikic
Copy link
Member

@nikic nikic commented Apr 9, 2020

A problem here is that the extra parameters show up in exception stack traces, and make tests spuriously fail.

@nikic nikic changed the title Add mode for verifying internal function params Add mode for verifying internal function param defaults Apr 9, 2020
@nikic nikic force-pushed the internal-default-verification branch from cdf7025 to 0257cac Compare April 9, 2020 14:55
@nikic
Copy link
Member Author

nikic commented Apr 9, 2020

cc @kocsismate

Ugh internal functions are so weird.

@kocsismate
Copy link
Member

@nikic OMG, all these failures are due to bad default values? 😱I'll try to have a look at them

@cmb69
Copy link
Member

cmb69 commented Apr 10, 2020

Fixing the session_set_save_handler() stub should fix about half of the test failures. Either switch all default values to UNKNOWN, or have the second parameter variadic (which actually is more like what ZPP does).

@cmb69
Copy link
Member

cmb69 commented Apr 10, 2020

 ext/session/session.stub.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ext/session/session.stub.php b/ext/session/session.stub.php
index 09c35aae28..8c13281243 100644
--- a/ext/session/session.stub.php
+++ b/ext/session/session.stub.php
@@ -37,7 +37,7 @@ function session_register_shutdown(): void {}
 /** @alias session_write_close */
 function session_commit(): bool {}
 
-function session_set_save_handler($open, $close = null, $read = null, $write = null, $destroy = null, $gc = null, $create_sid = null, $validate_sid = null, $update_timestamp = null): bool {}
+function session_set_save_handler($open, $close = UNKNOWN, $read = UNKNOWN, $write = UNKNOWN, $destroy = UNKNOWN, $gc = UNKNOWN, $create_sid = UNKNOWN, $validate_sid = UNKNOWN, $update_timestamp = UNKNOWN): bool {}
 
 function session_cache_limiter(string $cache_limiter = UNKNOWN): string|false {}
 
@@ -45,7 +45,7 @@ function session_cache_expire(?int $new_cache_expire = null): int|false {}
 
 function session_set_cookie_params($lifetime_or_options, string $path = UNKNOWN, string $domain  = "", ?bool $secure = null, ?bool $httponly = null): bool {}
 
-function session_start(array $options = []): bool {}
+function session_start(array $options = UNKNOWN): bool {}
 
 interface SessionHandlerInterface
 {

fixes all ext/session test failures for me.

@nikic
Copy link
Member Author

nikic commented Apr 10, 2020

@cmb69 The session_set_save_handler change looks good to me, but why the session_start change?

@kocsismate
Copy link
Member

@nikic I've fixed quite some issues. Please, rebase when you'll have time so that I can see the remaining issues more easily :)

@nikic nikic force-pushed the internal-default-verification branch from 0257cac to 404fb15 Compare April 10, 2020 16:19
@kocsismate
Copy link
Member

@nikic If all the wishes would come true this fast... :D

@cmb69
Copy link
Member

cmb69 commented Apr 11, 2020

The session_set_save_handler change looks good to me, but why the session_start change?

Oh, indeed, the signature is correct; however, session_set_save_handler_sid_002.phpt and two other tests fail on AppVeyor and locally for me because of a slightly different stack trace. Why is the argument shown on Windows, but not on Linux?

@kocsismate
Copy link
Member

kocsismate commented Apr 11, 2020

Am I right that the default value of the $errno and the $errstr parameters of stream_socket_client() and stream_socket_server() shouldn't be null (because ZVAL null != null)?

@cmb69
Copy link
Member

cmb69 commented Apr 11, 2020

@kocsismate, yes.

@kocsismate
Copy link
Member

As far as I see there will lots of issues with null default values of non-nullable parameters (at least ext/filter had quite some), so I think starting the overhaul of nullable parameters has just become very necessary. :/

@cmb69 cmb69 added the Feature label Apr 12, 2020
@nikic nikic force-pushed the internal-default-verification branch from 404fb15 to b9b297a Compare April 14, 2020 14:10
nikic added a commit to nikic/php-src that referenced this pull request Apr 14, 2020
To avoid printing arguments in exception backtrace. This reduces
false positives for phpGH-5366.
@nikic nikic force-pushed the internal-default-verification branch from b9b297a to 52b1841 Compare April 14, 2020 15:41
@kocsismate
Copy link
Member

@nikic Can you please rebase this next week? It's not urgent at all, but we should have a look at the current state soon :)

@nikic nikic force-pushed the internal-default-verification branch 2 times, most recently from 4aedb8b to bba66f9 Compare October 13, 2020 15:32
@nikic
Copy link
Member Author

nikic commented Oct 13, 2020

A few next weeks later, this is now rebased :) I've already fixed a couple of issues that have cropped up.

@nikic nikic force-pushed the internal-default-verification branch 2 times, most recently from 2863536 to 5501c17 Compare October 14, 2020 14:41
@nikic nikic mentioned this pull request Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants