[PHP-DEV] request to add

2018-01-17 Thread Sam Ding


Sam Ding,
Linux on z Systems  Open Source Ecosystem
IBM Toronto Lab,
email: samd...@ca.ibm.com
phone: (905)413-2947


[PHP-DEV] unit test a single case

2018-01-17 Thread Sam Ding

Hi PHP developers,

I am new and  try to porting php v7.2.1 on IBM s390x, after building and
run unit test "make test", there are
some failed cases. Is there any way I can run a single case and get the
result?
Further how to debug a php unit case code?

Thanks,

Sam Ding,
Linux on z Systems  Open Source Ecosystem
IBM Toronto Lab,
email: samd...@ca.ibm.com
phone: (905)413-2947


[PHP-DEV] function stream_isatty

2018-01-18 Thread Sam Ding

There are 5 test cases that have different results between s390x and
x86_64:


|-|
|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]|
|-|



All are related to the new function stream_isatty().
Here is a short sample php:

   # more sample.php
   

[PHP-DEV] Big_Endian problem

2018-01-19 Thread 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


Re: [PHP-DEV] Big_Endian problem

2018-01-22 Thread 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


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

> From: Sara Golemon 
> To: Sam Ding 
> Cc: PHP internals 
> Date: 01/19/2018 05:07 PM
> Subject: Re: [PHP-DEV] Big_Endian problem
> Sent by: p...@golemon.com
>
> On Fri, Jan 19, 2018 at 4:04 PM, Sam Ding  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
>


[PHP-DEV] v7.2.1 test cases crash on s390x

2018-01-22 Thread Sam Ding

Hi,

When testing v7.2.1 on s390x two cases are found crash:

  1) ext/mbstring/tests/mb_ereg.phpt ;
  2) ext/mbstring/tests/mb_ereg_variation5.phpt] ;

It happens at /home/work/php/php/ext/mbstring/oniguruma/src/regexec.c:2481,
here is the code (replaced the macros):

2474case OP_STATE_CHECK_PUSH:  MOP_IN(OP_STATE_CHECK_PUSH);
2475  GET_STATE_CHECK_NUM_INC(mem, p);
2476//  STATE_CHECK_VAL(scv, mem);
2477 do {
2478  if (state_check_buff != NULL) {
2479//int x = STATE_CHECK_POS(s,mem);
2480int x = (((s) - str) * num_comb_exp_check + ((mem) - 1));
2481(scv) = state_check_buff[x/8] & (1<<(x%8));
2482  }
2483  else (scv) = 0;
2484} while(0);
2485
(gdb) p x
$1 = 196680
(gdb) p x/8
$2 = 24585

However the array "state_check_buff" index is 0--20311.
 "mem" is come from the  macro "GET_STATE_CHECK_NUM_INC", which refers to
"StateCheckNumType",
Here is the definition of StateCheckNumType: in
ext/mbstring/oniguruma/src/regint.h
  ...
530 typedef int MemNumType;
531 typedef short int StateCheckNumType;
532 typedef void* PointerType;
  ...

  Not understanding why StateCheckNumType is defined as short int, but
others are all int.

If change it as "int", two crashes are gone and  5 cases related to
"mb_ereg() " are passed.
Testing on x86_64  show 5 cases are alos passed (same as before).

Thanks,

Sam


[PHP-DEV] return values of socket_recvmsg

2018-01-25 Thread Sam Ding

The test case  ext/sockets/tests/socket_recvmsg.php  has following output
on x86_64:

===
...
1 Array
2 (
3[name] => Array
4(
5[family] => 10
6[addr] => ::1
7[port] => 7001
8[flowinfo] => 0
9[scope_id] => 0
10)
11
12[control] => Array
13   (
14[0] => Array
15   (
16[level] => 41
17[type] => 50
18[data] => Array
19   (
20[addr] => ::1
21[ifindex] => 1
22)
23)
24)
...
===
This is output  by c
function:"socket_recvmsg"(/home/work/php/php/ext/sockets/sendrecvmsg.c:214),
 which returns a struct "executor_globals.current_execute_data".

The struct  is defined as :

(gdb)  ptype executor_globals.current_execute_data
type = struct _zend_execute_data {
const zend_op *opline;
zend_execute_data *call;
zval *return_value;
zend_function *func;
zval This;
zend_execute_data *prev_execute_data;
zend_array *symbol_table;
void **run_time_cache;
zval *literals;
} *

Where do  the above output values  (line 18-21) store in the struct
_zend_execute_data ?


Thanks,

Sam


Re: [PHP-DEV] return values of socket_recvmsg

2018-01-26 Thread Sam Ding

Thank Kalle,

I knew the implementaion of socket_recvmsg(), but want to know the return
data structure.
The test on Big_endian (s390x) got a little different return result than on
x86_64, try to dig out
where the problem is.

Thanks,

Sam


kalle@gmail.com wrote on 01/26/2018 01:58:23 AM:

> From: Kalle Sommer Nielsen 
> To: Sam Ding 
> Cc: PHP internals 
> Date: 01/26/2018 01:58 AM
> Subject: Re: [PHP-DEV] return values of socket_recvmsg
> Sent by: kalle@gmail.com
>
> Hi Sam
>
> 2018-01-25 23:11 GMT+01:00 Sam Ding :
> >
> > The test case  ext/sockets/tests/socket_recvmsg.php  has following
output
> > on x86_64:
> >
> > ===
> > ...
> > 1 Array
> > 2 (
> > 3[name] => Array
> > 4(
> > 5[family] => 10
> > 6[addr] => ::1
> > 7[port] => 7001
> > 8[flowinfo] => 0
> > 9[scope_id] => 0
> > 10)
> > 11
> > 12[control] => Array
> > 13   (
> > 14[0] => Array
> > 15   (
> > 16[level] => 41
> > 17[type] => 50
> > 18[data] => Array
> > 19   (
> > 20[addr] => ::1
> > 21[ifindex] => 1
> > 22)
> > 23)
> > 24)
> > ...
> > ===
> > This is output  by c
> >
function:"socket_recvmsg"(/home/work/php/php/ext/sockets/sendrecvmsg.c:214),

>
> You can find the implementation of socket_recvmsg() in the ext/sockets
> directory here:
> https://urldefense.proofpoint.com/v2/url?
>
u=http-3A__git.php.net_-3Fp-3Dphp-2Dsrc.git-3Ba-3Dblob-3Bf-3Dext_sockets_sendrecvmsg.c-3Bh-3D7b9c4e8ad357b73b514dc5feb8dc8d9ca215126b-3Bhb-3DHEAD-23l210&d=DwIBaQ&c=jf_iaSHvJObTbx-

> siA1ZOg&r=CBZ1IFMUPf-s4Wt-
>
elABGKFWisr3DNfFfWYNaKkXXUE&m=f8KTE9WyceLmQxKXG77FBkDIVqCnJ54BBnXEQuSQCo4&s=GOFChuk86IBBBORDL3I50gHrzmF4kTmYkq1qCeMufBQ&e=

>
>
>
> --
> regards,
>
> Kalle Sommer Nielsen
> ka...@php.net
>


Re: [PHP-DEV] return values of socket_recvmsg

2018-01-26 Thread Sam Ding
The return data in PHP is "$data" which is an array with 4 elements,
does it match to "zmsg" inside of c function
"socket_recvmsg"(/home/work/php/php/ext/sockets/sendrecvmsg.c:214)?

Here zmsg is struct with:

(gdb) ptype zmsg
type = struct _zval_struct {
zend_value value;
union {
struct {...} v;
uint32_t type_info;
} u1;
union {
uint32_t next;
uint32_t cache_slot;
uint32_t lineno;
uint32_t num_args;
uint32_t fe_pos;
uint32_t fe_iter_idx;
uint32_t access_flags;
uint32_t property_guard;
uint32_t extra;
} u2;
} *

How do these two variables match between php and C?

Thanks,

Sam

Sam Ding/Toronto/IBM wrote on 01/26/2018 09:36:00 AM:

> From: Sam Ding/Toronto/IBM
> To: Kalle Sommer Nielsen 
> Cc: PHP internals , kalle@gmail.com
> Date: 01/26/2018 09:36 AM
> Subject: Re: [PHP-DEV] return values of socket_recvmsg
>
> Thank Kalle,
>
> I knew the implementaion of socket_recvmsg(), but want to know the
> return data structure.
> The test on Big_endian (s390x) got a little different return result
> than on x86_64, try to dig out
> where the problem is.
>
> Thanks,
>
> Sam
>
>
> kalle....@gmail.com wrote on 01/26/2018 01:58:23 AM:
>
> > From: Kalle Sommer Nielsen 
> > To: Sam Ding 
> > Cc: PHP internals 
> > Date: 01/26/2018 01:58 AM
> > Subject: Re: [PHP-DEV] return values of socket_recvmsg
> > Sent by: kalle@gmail.com
> >
> > Hi Sam
> >
> > 2018-01-25 23:11 GMT+01:00 Sam Ding :
> > >
> > > The test case  ext/sockets/tests/socket_recvmsg.php  has following
output
> > > on x86_64:
> > >
> > > ===
> > > ...
> > > 1 Array
> > > 2 (
> > > 3[name] => Array
> > > 4(
> > > 5[family] => 10
> > > 6[addr] => ::1
> > > 7[port] => 7001
> > > 8[flowinfo] => 0
> > > 9[scope_id] => 0
> > > 10)
> > > 11
> > > 12[control] => Array
> > > 13   (
> > > 14[0] => Array
> > > 15   (
> > > 16[level] => 41
> > > 17[type] => 50
> > > 18[data] => Array
> > > 19   (
> > > 20[addr] => ::1
> > > 21[ifindex] => 1
> > > 22)
> > > 23)
> > > 24)
> > > ...
> > > ===
> > > This is output  by c
> > > function:"socket_recvmsg"(/home/work/php/php/ext/sockets/
> sendrecvmsg.c:214),
> >
> > You can find the implementation of socket_recvmsg() in the ext/sockets
> > directory here:
> > https://urldefense.proofpoint.com/v2/url?
> >
>
u=http-3A__git.php.net_-3Fp-3Dphp-2Dsrc.git-3Ba-3Dblob-3Bf-3Dext_sockets_sendrecvmsg.c-3Bh-3D7b9c4e8ad357b73b514dc5feb8dc8d9ca215126b-3Bhb-3DHEAD-23l210&d=DwIBaQ&c=jf_iaSHvJObTbx-

> > siA1ZOg&r=CBZ1IFMUPf-s4Wt-
> >
>
elABGKFWisr3DNfFfWYNaKkXXUE&m=f8KTE9WyceLmQxKXG77FBkDIVqCnJ54BBnXEQuSQCo4&s=GOFChuk86IBBBORDL3I50gHrzmF4kTmYkq1qCeMufBQ&e=

> >
> >
> >
> > --
> > regards,
> >
> > Kalle Sommer Nielsen
> > ka...@php.net
> >