php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76086 Unable to write to php://stderr
Submitted: 2018-03-13 05:11 UTC Modified: 2022-08-01 19:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: chris at modd dot com dot au Assigned:
Status: Open Package: CGI/CLI related
PHP Version: 7.2.3 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: chris at modd dot com dot au
New email:
PHP Version: OS:

 

 [2018-03-13 05:11 UTC] chris at modd dot com dot au
Description:
------------
Can no longer output to STDERR using file_put_contents. Used to work fine in PHP 5.x.
Also Affects 7.1.x

Test script:
---------------
<?php

$msg = "Error Occurred\n";
file_put_contents("php://stderr", $msg);


Expected result:
----------------
Error Occurred written to console on stderr

Actual result:
--------------
Rather than stderr output error message, I get a warning:
Only 0 of 15 bytes written, possibly out of free diskspace in script.php on line 3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-13 05:20 UTC] chris at modd dot com dot au
This problem only seems to be a problem when using php-cgi
 [2018-03-13 05:20 UTC] chris at modd dot com dot au
This problem only seems to be a problem when using php-cgi
 [2018-03-13 09:16 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2018-03-13 09:16 UTC] ab@php.net
Thanks for the report. I see this when running your snippet

$ php-cgi.exe bug76086.php 1>nul
Error Occurred

How exactly teh issue can be reproduced?

Thanks.
 [2018-03-13 21:50 UTC] chris at modd dot com dot au
-Status: Feedback +Status: Open
 [2018-03-13 21:50 UTC] chris at modd dot com dot au
I only get the error when running via fast-cgi. I am not sure how to reproduce this without running a webserver.
 [2018-03-14 00:16 UTC] chris at modd dot com dot au
Ok, I have found the bug more specifically.

You will need the cgi-fcgi command util from ubuntu/debian package: libfcgi0ldbl

Run fcgi server in dir with bugs76086.php script

PHP_FCGI_CHILDREN=1 php-cgi -b 127.0.0.1:9000

Then send a request from cli:

SCRIPT_NAME=bug76086.php SCRIPT_FILENAME=bug76086.php REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000

returns (from cgi-fci command, not terminal running php-cgi):
PHP Warning:  file_put_contents(): Only 0 of 2 bytes written, possibly out of free disk space in C:\Users\chris\bug76086.php on line 5
<br />
 [2018-03-14 17:23 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2018-03-14 17:23 UTC] ab@php.net
Thanks for the further info. libfcgi0ldbl is not a package from the PHP distribution. It is also unlikely available on Windows. Thus, seems it's not a PHP bug. From what is shown, i guess it's about the port doesn't get reused or similar. If there's a repro regarding PHP, please post, otherwise it's probably to be marked as not a bug.

Thanks.
 [2018-03-14 21:09 UTC] chris at modd dot com dot au
-Status: Feedback +Status: Open
 [2018-03-14 21:09 UTC] chris at modd dot com dot au
I am ONLY using the libfcgi0ldbl as a stand-in for running a webserver.

It fails exactly the same way using Apache with fastcgi, nginx with fastacgi and using a PHP fastcgi client. If you prefer I can write an example that uses the fcgi client used by the php unit tests.

https://github.com/php/php-src/blob/master/sapi/fpm/tests/fcgi.inc

using the cgi-fcgi package just means the example is simple to try and run and with Bash for windows, its easy enough to run it on windows too.
 [2018-03-14 21:25 UTC] aharvey@php.net
I can't reproduce this on Linux, so this looks Windows-specific.
 [2018-03-19 23:01 UTC] cmb@php.net
> If you prefer I can write an example that uses the fcgi client
> used by the php unit tests.

That would be great, since we prefer to have a PHPT regression
test to go along with the actual bug fix, anyway.
 [2020-09-22 09:15 UTC] cmb@php.net
-Operating System: Windows +Operating System: *
 [2020-09-22 09:15 UTC] cmb@php.net
> Used to work fine in PHP 5.x.

Not with PHP 5.6.40 on Windows.  Actually, this doesn't look like
a Windows specific issue to me, but rather depends on whether
stderr is actually writable.  Since php://stderr does not refer to
the multiplexed FCGI standard error stream[1], there may be no
stderr at all.

See also bug #79905.

[1] <https://bugs.php.net/bug.php?id=31472>
 [2022-08-01 19:00 UTC] bukka@php.net
-Package: Streams related +Package: CGI/CLI related
 [2022-08-01 19:00 UTC] bukka@php.net
This is up to SAPI to handle correctly. FPM has got a logic around this so this really seems to me like a CGI sapi related problem which is what I assume is used here. There is not much that can be done on stream level.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC