Big_Endian problem

  101630
January 19, 2018 21:04 samding@ca.ibm.com ("Sam Ding")
Hi all,

The test case ext/standard/tests/general_functions/bug72300.phpt is failed
on s390x.
The function "ignore_user_abort" returns "256" on s390x, and "1" on x86_64
after "ignore_user_abort" is set to true;
The root reason is because of Big_Endian on s390x.
Here is the C code:     ext/standard/basic_functions.c
b/ext/standard/basic_functions.c:5641

   old_setting = (unsigned short)PG(ignore_user_abort);
             //    php_core_globals.ignore_user_abort, "x /2b" shows its
value : "0x01 0x00" on both platforms

 Does PHP interpreter support Big_Endian? Are there any existing
macros/functions to deal with Big/Little Endian?


Thanks,

Sam Ding
  101632
January 19, 2018 22:07 pollita@php.net (Sara Golemon)
On Fri, Jan 19, 2018 at 4:04 PM, Sam Ding <samding@ca.ibm.com> wrote:
> The test case ext/standard/tests/general_functions/bug72300.phpt is failed > on s390x. > The function "ignore_user_abort" returns "256" on s390x, and "1" on x86_64 > after "ignore_user_abort" is set to true; > The root reason is because of Big_Endian on s390x. > Here is the C code: ext/standard/basic_functions.c > b/ext/standard/basic_functions.c:5641 > > old_setting = (unsigned short)PG(ignore_user_abort); > // php_core_globals.ignore_user_abort, "x /2b" shows its > value : "0x01 0x00" on both platforms > That specific line isn't the problem, as it's just cashing a short to
an unsigned short, which is legal and not problematic for any endianness. The actual problem is that PG(ignore_user_abort) is declared as a short, but its INI handler method is defined as OnUpdateBool (which of course, only operates on a single byte).
> Does PHP interpreter support Big_Endian? Are there any existing > macros/functions to deal with Big/Little Endian? > Yep. And if things break on s390x, please let us know!
I'll put together a fix for this over the weekend and apply it to 7.0 and later versions. -Sara
  101653
January 22, 2018 14:40 samding@ca.ibm.com ("Sam Ding")
Thank Sara.

Yes,  on s390x, it is broken.
The function "ignore_user_abort" returns "256" on s390x, and "1" on x86_64
after "ignore_user_abort" is set to true;

Please let me know when you finished code changes on v7.2.1. I will test on
s390x.

Thanks,

Sam


php@golemon.com wrote on 01/19/2018 05:07:25 PM:

> From: Sara Golemon <pollita@php.net> > To: Sam Ding <samding@ca.ibm.com> > Cc: PHP internals <internals@lists.php.net> > Date: 01/19/2018 05:07 PM > Subject: Re: [PHP-DEV] Big_Endian problem > Sent by: php@golemon.com > > On Fri, Jan 19, 2018 at 4:04 PM, Sam Ding <samding@ca.ibm.com> wrote: > > The test case ext/standard/tests/general_functions/bug72300.phpt is failed
> > on s390x. > > The function "ignore_user_abort" returns "256" on s390x, and "1" on x86_64
> > after "ignore_user_abort" is set to true; > > The root reason is because of Big_Endian on s390x. > > Here is the C code: ext/standard/basic_functions.c > > b/ext/standard/basic_functions.c:5641 > > > > old_setting = (unsigned short)PG(ignore_user_abort); > > // php_core_globals.ignore_user_abort, "x /2b" shows its
> > value : "0x01 0x00" on both platforms > > > That specific line isn't the problem, as it's just cashing a short to > an unsigned short, which is legal and not problematic for any > endianness. > > The actual problem is that PG(ignore_user_abort) is declared as a > short, but its INI handler method is defined as OnUpdateBool (which of > course, only operates on a single byte). > > > Does PHP interpreter support Big_Endian? Are there any existing > > macros/functions to deal with Big/Little Endian? > > > Yep. And if things break on s390x, please let us know! > > I'll put together a fix for this over the weekend and apply it to 7.0 > and later versions. > > -Sara >
  101661
January 23, 2018 14:04 pollita@php.net (Sara Golemon)
On Mon, Jan 22, 2018 at 9:40 AM, Sam Ding <samding@ca.ibm.com> wrote:
> > Yes, on s390x, it is broken. > Yeah, I'd confirmed that one. I meant any *additional* issues are
welcome as well. :D
> The function "ignore_user_abort" returns "256" on s390x, and "1" on x86_64 > after "ignore_user_abort" is set to true; > > Please let me know when you finished code changes on v7.2.1. I will test on > s390x. > Just got around to pushing:
https://github.com/php/php-src/commit/d46d53a7bcc99bb8d993852ef84e7a83d703f3db Thanks! -Sara