Bug #75864 [Opn->Csd]: "stream_isatty" returns wrong value on s390x
| From: | ab@php.net | Date: | Sat, 27 Jan 2018 16:27:24 +0000 |
| Subject: | Bug #75864 [Opn->Csd]: "stream_isatty" returns wrong value on s390x | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213724@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75864&edit=1
ID: 75864
Updated by: ab@php.net
Reported by: samding at ca dot ibm dot com
Summary: "stream_isatty" returns wrong value on s390x
-Status: Open
+Status: Closed
Type: Bug
Package: Streams related
Operating System: RHEL 7.2
PHP Version: 7.2.1
-Assigned To:
+Assigned To: ab
Block user comment: N
Private report: N
New Comment:
Fixed per a8c6b36d62b1a58be68a1e50ee4113351f1845e4.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2018-01-23 21:27:45] samding at ca dot ibm dot com
The root reason happens at /home/work/php/php_master/main/streams/plain_wrapper.c:578
578 *(php_socket_t *)ret = fd;
Note "php_socket_t" is int type (4 bytes) and "ret" (fileno) is long (8 bytes).
This point operation is sensitive on Big/Little Endian platform, it is ok on LE, but causes the
issue on BE.
The solution is change "fileno" to int type.
------------------------------------------------------------------------
[2018-01-23 18:38:11] samding at ca dot ibm dot com
Description:
------------
Test cases
Test stream_isatty with redirected STDERR [tests/output/stream_isatty_err.phpt]
Test stream_isatty with redirected STDIN/STDERR [tests/output/stream_isatty_in-err.phpt]
Test stream_isatty with redirected STDIN/STDOUT [tests/output/stream_isatty_in-out.phpt]
Test stream_isatty with redirected STDOUT [tests/output/stream_isatty_out.phpt]
Test stream_isatty with redirected STDOUT/STDERR [tests/output/stream_isatty_out-err.phpt]
Failed on s390x.
Test script:
---------------
Here is sample php code:
<?php
$closeMe = fopen(__FILE__, 'rb');
$tmp=stream_isatty($closeMe);
echo "closeme=$closeMe, stream_isatty=$tmp+\n";
echo "closeMe:"; var_dump(stream_isatty($closeMe));
gdb sapi/cli/php
(gdb) b zif_stream_isatty
(gdb) r case/sample.php
...
1651 RETVAL_BOOL(isatty(fileno));
(gdb) p fileno
$1 = 34359718632
(gdb) x /8b &fileno
0x3ffffffb360: 0 0 0 7 -1 -1 -78 -24
Seems the last 4 bytes of "fileno" wrong on s390x (Big_Endian)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75864&edit=1