Re: [PHP-CVS] com php-src: Fixed bug #64142 (dval to lval different behavior on ppc64): NEWS Zend/zend_operators.h

2013-02-05 Thread Remi Collet
After more test and looking better

Test result on ppc64


max, >0, >=1
9223372036854775808., 9223372036854775807,
0x7fff
9223372036854775808., -9223372036854775808,
0x8000
max+1, >0, >=1
9223372036854775808., 9223372036854775807,
0x7fff
9223372036854775808., -9223372036854775808,
0x8000
max+1, >1, >=1
9223372036854786048., 9223372036854775807,
0x7fff
9223372036854786048., -9223372036854765568,
0x80002800


Test result on x86_64

max, >0, >=1
9223372036854775808., -9223372036854775808,
0x8000
9223372036854775808., -9223372036854775808,
0x8000
max+1, >0, >=1
9223372036854775808., -9223372036854775808,
0x8000
9223372036854775808., -9223372036854775808,
0x8000
max+1, >1, >=1
9223372036854786048., -9223372036854775808,
0x8000
9223372036854786048., -9223372036854765568,
0x80002800

Test result on x86_64, build with -O2 (so, same as ppc64)

9223372036854775808., 9223372036854775807,
0x7fff
9223372036854775808., -9223372036854775808,
0x8000
max+1, >0, >=1
9223372036854775808., 9223372036854775807,
0x7fff
9223372036854775808., -9223372036854775808,
0x8000
max+1, >1, >=1
9223372036854786048., 9223372036854775807,
0x7fff
9223372036854786048., -9223372036854765568,
0x80002800

So, this show that > is the good test, so I have reverted the fix.

So, the problem is elsewhere, I will search, probably using the others
failed tests output.

Thanks for catching this.

Remi.


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Fixed bug #64142 (dval to lval different behavior on ppc64): NEWS Zend/zend_operators.h

2013-02-05 Thread Rasmus Lerdorf
On 02/05/2013 12:33 AM, Remi Collet wrote:
> Le 05/02/2013 08:54, Stas Malyshev a écrit :
>> Hi!
>>
>>> -   if (d > LONG_MAX) {
>>> +   if (d >= LONG_MAX) {
>>> return (long)(unsigned long) d;
>>> }
>>> return (long) d;
>>
>> Could you please explain this one? I thought LONG_MAX is a largest
>> permissible long value, why when d==LONG_MAX we need to convert?
> 
> LONG_MAX is the largest "unsigned" value.
> We have different int/float conversion result on some arch (detected, at
> least on ppc64).
> 
>long l = 0x7fff;
>double d;
>d = l;
>d++;
>printf("max+1=%lf, %ld, 0x%lx\n", d, (long)d, (long)d);
>printf("max+1=%lf, %ld, 0x%lx\n", d, (long)(unsigned long)d,
> (long)(unsigned long)d);
> 
> 
> On x86_64
> max+1=9223372036854786048.00, -9223372036854775808, 0x8000
> max+1=9223372036854786048.00, -9223372036854765568, 0x80002800
> 
> ON ppc64
> 
> max+1=9223372036854775808.00, 9223372036854775807, 0x7fff
> max+1=9223372036854775808.00, -9223372036854775808, 0x8000
> 
> So we are in a really border case...
> 
>> Also, why this patch - which seems to be a BC break since it exhibits
>> different behavior on 64-bit systems - needs to be in 5.4?
> 
> This patch doesn't change behavior on x86 arch.
> It fixes 9 failed test on ppc64.

I guess the confusion here is that without an #ifdef PPC around this,
how is this not triggering the conversion earlier on x86?

Also, I tried your test program on my x86_64 Linux box and I don't get
the same result:

I get:

max+1=9223372036854775808.00, -9223372036854775808, 0x8000
max+1=9223372036854775808.00, -9223372036854775808, 0x8000

gcc-4.7, glibc-2.15

-Rasmus

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Fixed bug #64142 (dval to lval different behavior on ppc64): NEWS Zend/zend_operators.h

2013-02-05 Thread Remi Collet
Le 05/02/2013 08:54, Stas Malyshev a écrit :
> Hi!
> 
>> -if (d > LONG_MAX) {
>> +if (d >= LONG_MAX) {
>>  return (long)(unsigned long) d;
>>  }
>>  return (long) d;
> 
> Could you please explain this one? I thought LONG_MAX is a largest
> permissible long value, why when d==LONG_MAX we need to convert?

LONG_MAX is the largest "unsigned" value.
We have different int/float conversion result on some arch (detected, at
least on ppc64).

   long l = 0x7fff;
   double d;
   d = l;
   d++;
   printf("max+1=%lf, %ld, 0x%lx\n", d, (long)d, (long)d);
   printf("max+1=%lf, %ld, 0x%lx\n", d, (long)(unsigned long)d,
(long)(unsigned long)d);


On x86_64
max+1=9223372036854786048.00, -9223372036854775808, 0x8000
max+1=9223372036854786048.00, -9223372036854765568, 0x80002800

ON ppc64

max+1=9223372036854775808.00, 9223372036854775807, 0x7fff
max+1=9223372036854775808.00, -9223372036854775808, 0x8000

So we are in a really border case...

> Also, why this patch - which seems to be a BC break since it exhibits
> different behavior on 64-bit systems - needs to be in 5.4?

This patch doesn't change behavior on x86 arch.
It fixes 9 failed test on ppc64.

This is a very very old bug
http://marc.info/?l=php-internals&m=109360955403511
(this patch wasn't correct, but the issue was the same)

Probably most people don't care in previous version (<5.4), where test
suite was in a quite awfull state.

Now than we have a good test suite (0 failed test in x86), I think it is
interesting to do some work on other arch (and hopefully, I have a ppc64
test machine available).


Regards,
Remi.


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Fixed bug #64142 (dval to lval different behavior on ppc64): NEWS Zend/zend_operators.h

2013-02-05 Thread Remi Collet
Le 05/02/2013 08:25, Rasmus Lerdorf a écrit :
> On 02/04/2013 06:19 AM, Remi Collet wrote:
>> Commit:6533094d9e4d0c85044a170d9fad9a3986a68675
>> Author:Remi Collet  Mon, 4 Feb 2013 15:19:32 +0100
>> Parents:   740b823be80a29e4c6537d4053eb7bad0fae6c41
>> Branches:  PHP-5.4 PHP-5.5 master
>>
>> Link:   
>> http://git.php.net/?p=php-src.git;a=commitdiff;h=6533094d9e4d0c85044a170d9fad9a3986a68675
> 
> Maybe add a test case for this one?

We already have:

tests/lang/operators/bitwiseAnd_basiclong_64bit.phpt
tests/lang/operators/bitwiseNot_basiclong_64bit.phpt
tests/lang/operators/bitwiseOr_basiclong_64bit.phpt
tests/lang/operators/bitwiseXor_basiclong_64bit.phpt
tests/lang/operators/modulus_basiclong_64bit.phpt
ext/standard/tests/math/decbin_basiclong_64bit.phpt
ext/standard/tests/math/dechex_basiclong_64bit.phpt
ext/standard/tests/math/decoct_basiclong_64bit.phpt
ext/standard/tests/strings/chunk_split_variation2.php

All this tests were failing on ppc64.

For your information
Before built-in server fix : 46 failed test
Before this fix : 25
Still to fix : 16


Remi.


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Fixed bug #64142 (dval to lval different behavior on ppc64): NEWS Zend/zend_operators.h

2013-02-04 Thread Stas Malyshev
Hi!

> - if (d > LONG_MAX) {
> + if (d >= LONG_MAX) {
>   return (long)(unsigned long) d;
>   }
>   return (long) d;

Could you please explain this one? I thought LONG_MAX is a largest
permissible long value, why when d==LONG_MAX we need to convert?

Also, why this patch - which seems to be a BC break since it exhibits
different behavior on 64-bit systems - needs to be in 5.4?

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Fixed bug #64142 (dval to lval different behavior on ppc64): NEWS Zend/zend_operators.h

2013-02-04 Thread Rasmus Lerdorf
On 02/04/2013 06:19 AM, Remi Collet wrote:
> Commit:6533094d9e4d0c85044a170d9fad9a3986a68675
> Author:Remi Collet  Mon, 4 Feb 2013 15:19:32 +0100
> Parents:   740b823be80a29e4c6537d4053eb7bad0fae6c41
> Branches:  PHP-5.4 PHP-5.5 master
> 
> Link:   
> http://git.php.net/?p=php-src.git;a=commitdiff;h=6533094d9e4d0c85044a170d9fad9a3986a68675

Maybe add a test case for this one?


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php