bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* timespec test failure on Linux/s390x
@ 2021-08-30  1:15 Bruno Haible
  2021-08-30  1:49 ` Paul Eggert
  0 siblings, 1 reply; 6+ messages in thread
From: Bruno Haible @ 2021-08-30  1:15 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

In a testdir of all of Gnulib, on Linux/s390x, test-timespec fails:

../../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:

test = {{tv_sec = -9223372036854775808, tv_nsec = -1},
        {tv_sec = -9223372036854775808, tv_nsec = 0},
        {tv_sec = -9223372036854775808, tv_nsec = 1},
        {tv_sec = -9223372036854775808, tv_nsec = 999999999},
        {tv_sec = -9223372036854775807, tv_nsec = 0},
        {tv_sec = -9223372036854775807, tv_nsec = 1},
        {tv_sec = -9223372036854775807, tv_nsec = 999999999},
        {tv_sec = -1, tv_nsec = 0},
        {tv_sec = -1, tv_nsec = 1},
        {tv_sec = -1, tv_nsec = 999999999},
        {tv_sec = 0, tv_nsec = 0},
        {tv_sec = 0, tv_nsec = 1},
        {tv_sec = 0, tv_nsec = 999999999},
        {tv_sec = 1, tv_nsec = 0},
        {tv_sec = 1, tv_nsec = 1},
        {tv_sec = 1, tv_nsec = 999999999},
        {tv_sec = 1234567890, tv_nsec = 0},
        {tv_sec = 1234567890, tv_nsec = 1},
        {tv_sec = 1234567890, tv_nsec = 999999999},
        {tv_sec = 9223372036854775806, tv_nsec = 0},
        {tv_sec = 9223372036854775806, tv_nsec = 1},
        {tv_sec = 9223372036854775806, tv_nsec = 999999999},
        {tv_sec = 9223372036854775807, tv_nsec = 0},
        {tv_sec = 9223372036854775807, tv_nsec = 1},
        {tv_sec = 9223372036854775807, tv_nsec = 999999999},
        {tv_sec = 9223372036854775807, tv_nsec = 2000000000}}
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}
diff = {tv_sec = 0, tv_nsec = 0}
rdiff = {tv_sec = 0, tv_nsec = 0}
k = 13
c = {tv_sec = 1, tv_nsec = 0}
sumbc = {tv_sec = -9223372036854775807, tv_nsec = 0}
timespec_add (a, sumbc) = {tv_sec = -9223372036854775808, tv_nsec = 0}
timespec_add (sum, c) = {tv_sec = 1, tv_nsec = 0}

* Questions:
Is timespec_add (a, sumbc) wrong?
Or does this particular triple (a, b, c) need to be exluded from the tests?

* struct timespec is defined as:

struct timespec
{
  __time_t tv_sec;              /* Seconds.  */
  ...
};

and apparently __time_t is 64 bits wide and signed.

* Debugging the relevant invocation of timespec_add (a, sumbc):

#0  timespec_add (a=..., b=...) at ../../gllib/timespec-add.c:30
30      {
(gdb) next
31        time_t rs = a.tv_sec;
(gdb) 
32        time_t bs = b.tv_sec;
(gdb) 
33        int ns = a.tv_nsec + b.tv_nsec;
(gdb) print rs
$4 = -9223372036854775808
(gdb) print bs
$5 = -9223372036854775807
(gdb) next
34        int nsd = ns - TIMESPEC_HZ;
(gdb) 
35        int rns = ns;
(gdb) 
37        if (0 <= nsd)
(gdb) 
49        if (INT_ADD_WRAPV (rs, bs, &rs))
(gdb) 
51            if (bs < 0)
(gdb) 
53                rs = TYPE_MINIMUM (time_t);
(gdb) 
54                rns = 0;
(gdb) 
64        return make_timespec (rs, rns);
(gdb) print rs
$6 = -9223372036854775808


Bruno





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-12 22:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30  1:15 timespec test failure on Linux/s390x Bruno Haible
2021-08-30  1:49 ` Paul Eggert
2021-08-30  2:39   ` Bruno Haible
2021-09-12 15:28   ` Bruno Haible
2021-09-12 19:40     ` Paul Eggert
2021-09-12 22:44       ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).