bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: timespec test failure on Linux/s390x


From: Paul Eggert
Subject: Re: timespec test failure on Linux/s390x
Date: Sun, 29 Aug 2021 18:49:59 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 8/29/21 6:15 PM, Bruno Haible wrote:

../../gltests/test-timespec.c:152: assertion 'eq (timespec_add (a, sumbc), 
timespec_add (sum, c))' failed
Aborted (core dumped)

In test-timespec.c:152 the local variables are:
...
ntests = 26
computed_hz = 1000000000
i = 1
a = {tv_sec = -9223372036854775808, tv_nsec = 0}
roundtrip = {tv_sec = -9223372036854775808, tv_nsec = 0}
prevroundtrip = {tv_sec = -9223372036854775808, tv_nsec = 0}
j = 1
b = {tv_sec = -9223372036854775808, tv_nsec = 0}
sum = {tv_sec = 0, tv_nsec = 0}

That value of 'sum' is wrong; it should be most-negative value {tv_sec = -9223372036854775808, tv_nsec = 0} because A and B are both that value, and 'sum = timespec_add (a, b)' is supposed to be saturated addition.

My guess is that timespec-add.c's line 49 'INT_ADD_WRAPV (rs, bs, &rs)' is not correctly returning true when RS and BS are both the most-negative value. Since you're using GCC, line 49 should be equivalent to '__builtin_add_overflow (rs, bs, &rs)' (though you should check this), and that suggests a GCC bug. (Yes, I know, everybody at first blames the compiler. :-)

Which version of GCC are you using? <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269> says that __builtin_add_overflow does not work in GCC 6.5 on s390x, and that the bug is fixed in GCC 7. Could this be the problem?

sumbc = {tv_sec = -9223372036854775807, tv_nsec = 0}
timespec_add (a, sumbc) = {tv_sec = -9223372036854775808, tv_nsec = 0}
...> * Questions:
Is timespec_add (a, sumbc) wrong?

No, it's right.

Or does this particular triple (a, b, c) need to be exluded from the tests?

I suspect the bug is in the earlier call to timespec_add, as mentioned above.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]