-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
fwrite to php://stderr throws E_NOTICE on php 7.4 #420
Comments
It triggers E_NOTICE when strerr is closed since PHP 7.4. Maybe here Line 128 in 170b379
|
I remember there was a problem with stderr on Windows. If stderr output was too long, test got stuck. The reason was, that Windows somehow use the same output buffer (or something like that) for stdout and stderr and PHP got stuck on reading stdout when stderr was full and vice versa. It was in PHP 5.4 times. Not sure how about PHP 7. Beside of that. Imagine that Job catches stdin and stdout, and test produces:
we are not able to reconstruct that in Runner output, there are not output timestamps. So we get:
|
The problem with stderr also affects PHP 7.4. |
related php/php-src@d59aac5 |
I just encountered this error too with PHP 8.1. We use Nette tester to test our dev-tools. When Nette tester calls command throught symfony console it ends with this error when it outputs last line to stderr. When we run test directly then it works. Any idea what might be the cause? It seems like stderr of test child process is for some reason closed prematurely by tester but I have no idea why. |
Ok after some digging it seems that reson is simple. Stderr of job is closed even before it is run here (as @dg mentioned earlier): Line 130 in fd9d510
Is there any reson to close it? When process running in Job tries for any reson to write to stderr it will eventually produce errors. Also RUN_COLLECT_ERRORS is useful feature and it would solve this issue in our case but I see no way how to pass this flag to tester jobs. What am I missing? |
As solution I would suggest never close stderr of job and make RUN_COLLECT_ERRORS either default behaviour or add CLI parameter to turn it on (--collect-errors? --collect-stderr?) I could prepere PR if you want. |
The reason was unpredictable behaviour as I wrote earlier there, process hangouts. |
@milo Unpredistable behaviour as unpredictalbe order or outputs? Even if stderr is ignored we do not have to close it no? Also when there is both stdout and stderr we can print it something like this:
I have seem this solution used in some tools. I am not sure what you mean by process hangouts. |
Sorry, I'm on mobile only... Unpredictable stability. It used to be at least. When stderr was too long, reading from stdout got stuck. Whole process got stuck and has to be killed. Maybe using |
@milo Is this bug still an issue? I reread discussion in #86 nad PHP bug that caused it https://bugs.php.net/bug.php?id=64438 might be fixed since 2014-09-29 |
Well, it looks like we can try it. |
Ok any idea how we can test it? Just run Job that outputs huge stdout and stderr? |
I tried, it doesn't work even in PHP 8.1. |
Damn. Can you sum up how you tested it? Are all OS affected of is it OS specific? |
What about that old idea of redirecting stderr to temp file? |
Since we introduced temporary dir, it is possible. But how to show it/test it? Print it whole when test finished? Or test it separated by new annotation? Or redirect stdout and stderr into the same file and print it, so emulate behaviour of standalone test? I have no use case for it so I don't know. |
IMHO best option would be reditect both stdout and stderr to same file. But last time we discussed it @db did not liked this idea and wanted separated captures. So I would go for separate capture and keep current behaviour already used with RUN_COLLECT_ERRORS. And I would output it same way as we output stdout. Just in case there is stderr i would append something like:
I can draft PR and then we can finalize it. |
test.phpt: <?php file_put_contents('php://stderr', str_repeat('e', 5030)); Job.php line 127: // if ($flags & self::RUN_COLLECT_ERRORS) {
$this->stderr = $stderr;
// } else {
// fclose($stderr);
// } Tested on Windows 11 |
I drafted PR #438 with capture of stderr to temp file and added STDERR to test output. Updated tests included. |
Version: 2.3.2
Bug Description
Function
fwrite
tophp://stderr
throwsE_NOTICE
on php 7.4. On php 7.3 and 7.2 behaves correctly.Steps To Reproduce
Run test separately via
php fwrite.phpt
behaves as expected.Expected Behavior
Write text to stderr, same as run test separately.
The text was updated successfully, but these errors were encountered: