Re: Broken tests
| From: | Keyur Govande | Date: | Fri, 26 Dec 2014 20:21:40 +0000 |
| Subject: | Re: Broken tests | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-83886@lists.php.net to get a copy of this message | ||
On Fri, Dec 26, 2014 at 1:13 PM, Dmitry Stogov <dmitry@zend.com> wrote:
> $ gcc --version
> gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)
>
> $ rpm -qa | grep -i mariadb
> mariadb-libs-5.5.39-1.fc19.x86_64
> mariadb-devel-5.5.39-1.fc19.x86_64
> mariadb-server-5.5.39-1.fc19.x86_64
> mariadb-libs-5.5.39-1.fc19.i686
> mariadb-5.5.39-1.fc19.x86_64
>
> Thanks. Dmitry.
>
>
Thanks Dmitry.
I have a program to reproduce the issue and you're initial hunch about
volatile was totally correct.
#include <stdio.h>
#include <string.h>
double getValue(float f) {
typedef float dec32 __attribute__((mode(SD)));
dec32 d32 = f;
return (double)d32;
}
int main(int argc, char **argv) {
float f = 3.14159274f;
double good = getValue(f);
double bad = (double)f;
printf("good double: %.15f, bad double: %.15f, (good == bad): %d\n",
good, bad, (good == bad));
return 0;
}
I had developed the feature using gcc 4.4.7 and the feature works
flawlessly over there. The output with -O2 is:
good double: 3.141593000000000, bad double: 3.141592741012573, (good ==
bad): 0
When the exact same code is compiled with gcc 4.8.3 and -O2 though the
compiler optimizes away the conversion and the output becomes:
good double: 3.141592741012573, bad double: 3.141592741012573, (good ==
bad): 1
When I add a volatile to the assignment of variable "d32" though, the
optimization is removed and the output is again as expected. Note that with
gcc 4.8.3 and -O0 the compiler does not try to be clever and hence the
output is the same as with gcc 4.4.7 which is why the DEBUG build continues
to work.
With the fix the tests pass again. I will commit a fix to the repo.
>
> On Fri, Dec 26, 2014 at 9:09 PM, Keyur Govande <keyurgovande@gmail.com>
> wrote:
>
>>
>>
>> On Fri, Dec 26, 2014 at 1:07 PM, Dmitry Stogov <dmitry@zend.com> wrote:
>>
>>> I'm not sure if these results reflect the latest committed tests...
>>> But we definitely have some problem.
>>>
>>> I also tried "9.99" as was mentioned in your comments and got
>>> "9.99" in
>>> DEBUG build but, "9.99899..." in RELEASE and build with libmysql.
>>>
>>
>> So to get my environment set up correctly, can you tell me the versions
>> of gcc/clang, libmysqlclient, the Mysql server and PHP you're using?
>>
>>
>>>
>>> Thanks. Dmitry.
>>>
>>> > mysqli fetch float values [ext/mysqli/tests/010.phpt]
>>> > mysqli fetch mixed values [ext/mysqli/tests/011.phpt]
>>> > mysqli fetch mixed values 2 [ext/mysqli/tests/012.phpt]
>>>
>>> $ cat ../ext/mysqli/tests/010.diff
>>> 003+ float(3.141593)
>>> 003- float(3.14159274101)
>>> 005+ float(-1.0E-6)
>>> 005- float(-9.99999997475E-7)
>>> 009+ float(1.0E+12)
>>> 009- float(999999995904)
>>> 011+ float(0.5646425)
>>> 011- float(0.564642488956)
>>> 015+ float(8.888889E+14)
>>> 015- float(8.88888914608E+14)
>>>
>>> $ cat ../ext/mysqli/tests/011.diff
>>> 011+ float(2345.6)
>>> 011- float(2345.60009766)
>>>
>>> $ cat ../ext/mysqli/tests/012.diff
>>> 011+ float(2.6)
>>> 011- float(2.59999990463)
>>>
>>> On Fri, Dec 26, 2014 at 8:56 PM, Keyur Govande <keyurgovande@gmail.com>
>>> wrote:
>>>
>>>>
>>>>
>>>> On Fri, Dec 26, 2014 at 12:53 PM, Dmitry Stogov <dmitry@zend.com>
>>>> wrote:
>>>>
>>>>> Hi Keyer,
>>>>>
>>>>> In my tests (Linux x86 and x86_64) the current behavior of mysqlnd
>>>>> differ form libmysql.
>>>>>
>>>>> Also your patch works differently in DEBUG and RELEASE mode.
>>>>> GCC just eliminates double conversion and makes your patch useless for
>>>>> RELEASE build (this may be fixed adding "volatile")
>>>>> I'm not completely sure what behavior is right.
>>>>> It would be great if you decide what should be done with Andrey and
>>>>> fix this.
>>>>>
>>>>> The fixes back and forth were done because of misunderstanding of real
>>>>> problem.
>>>>>
>>>>> Thanks. Dmitry.
>>>>>
>>>>
>>>> Hi Dmitry,
>>>>
>>>> Can you provide a test script and outputs you're seeing so I can try to
>>>> reproduce it?
>>>>
>>>>
>>>>>
>>>>>
>>>>> On Fri, Dec 26, 2014 at 8:25 PM, Keyur Govande <keyurgovande@gmail.com
>>>>> > wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Dec 26, 2014 at 10:14 AM, Dmitry Stogov <dmitry@zend.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> It seems like the source of the problem is commit c044164a authored
>>>>>>> by Keyur,
>>>>>>>
>>>>>>> I caught the problem because the behavior is different in DEBUG and
>>>>>>> RELEASE builds.
>>>>>>> However, I think the behavior introduced by that patch may be wrong.
>>>>>>> At least it produces different results in comparison to libmysql.
>>>>>>>
>>>>>>> Andrey, please made a decision.
>>>>>>>
>>>>>>> Thanks. Dmitry.
>>>>>>>
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I am a bit confused...I see that commit c2a047cf reverts my commit to
>>>>>> fix failing tests (4e2c016). But then c2a047cf was also reverted back by
>>>>>> 4409b6db3 a few hours back.
>>>>>>
>>>>>> Is there something I can help with? The original patch c044164a was
>>>>>> authored to fix bug #67839 and bring mysqli in parity with libmysql's
>>>>>> behavior on floating point numbers.
>>>>>>
>>>>>> Thanks,
>>>>>> Keyur.
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ---------- Forwarded message ----------
>>>>>>> From: Dmitry Stogov <dmitry@zend.com>
>>>>>>> Date: Fri, Dec 26, 2014 at 5:18 PM
>>>>>>> Subject: Broken tests
>>>>>>> To: Xinchen Hui <xinchen.h@zend.com>
>>>>>>> Cc: keyur_govande@yahoo.com, "php-cvs@lists.php.net" <
>>>>>>> php-cvs@lists.php.net>
>>>>>>>
>>>>>>>
>>>>>>> Hi Xinchen,
>>>>>>>
>>>>>>> The commit c2a047cf99f3d020bab12701e8dafed7424673bf made few tests
>>>>>>> to start fail on 32-bit DEBUG build. The same tests seems to work in
>>>>>>> RELEASE build.
>>>>>>>
>>>>>>> Are you sure these the are changed in a proper way?
>>>>>>> For me it looks like something was broken in code, and then tests
>>>>>>> were adjusted for wrong new behaviour.
>>>>>>>
>>>>>>> Please, find the source of the problem.
>>>>>>>
>>>>>>> Thanks. Dmitry.
>>>>>>>
>>>>>>> > mysqli fetch float values [ext/mysqli/tests/010.phpt]
>>>>>>> > mysqli fetch mixed values [ext/mysqli/tests/011.phpt]
>>>>>>> > mysqli fetch mixed values 2 [ext/mysqli/tests/012.phpt]
>>>>>>>
>>>>>>> $ cat ../ext/mysqli/tests/010.diff
>>>>>>> 003+ float(3.141593)
>>>>>>> 003- float(3.14159274101)
>>>>>>> 005+ float(-1.0E-6)
>>>>>>> 005- float(-9.99999997475E-7)
>>>>>>> 009+ float(1.0E+12)
>>>>>>> 009- float(999999995904)
>>>>>>> 011+ float(0.5646425)
>>>>>>> 011- float(0.564642488956)
>>>>>>> 015+ float(8.888889E+14)
>>>>>>> 015- float(8.88888914608E+14)
>>>>>>>
>>>>>>> $ cat ../ext/mysqli/tests/011.diff
>>>>>>> 011+ float(2345.6)
>>>>>>> 011- float(2345.60009766)
>>>>>>>
>>>>>>> $ cat ../ext/mysqli/tests/012.diff
>>>>>>> 011+ float(2.6)
>>>>>>> 011- float(2.59999990463)[dmitry@tpl2 CGI-DEBUG]$
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>