strace fails to build it's tests on arm-linux-gnueabihf with 64bit time_t

Bug #2060805 reported by Matthias Klose
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
strace
Fix Released
Unknown
strace (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

strace fails to build it's tests on arm-linux-gnueabihf with 64bit time_t

Related branches

Matthias Klose (doko)
tags: added: ftbfs
Changed in strace:
status: Unknown → New
Matthias Klose (doko)
tags: added: update-excuse
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Per check in ubuntu-release no one started to look into this so far.
I'm unsure if I can complete it with all the other release related things, but I'll leave what I've found here.

Strace defines an own time type in [1]

$ cat tests/kernel_old_timespec.h
...
typedef struct {
# if SIZEOF_KERNEL_LONG_T == 4 || defined LINUX_MIPSN32
 int
# else
 long long
# endif
 tv_sec, tv_nsec;
} kernel_old_timespec_t;
...

The conflict now is that on 32bit that boils down to int on e.g. armhf, but with 64 bit time_t that no more matches.
Due to that some assignments of ... (time_t) 0x1234LL can break if the static value is exceeding int.

Many places then later changed in [2] to not use time_t anymore and now usually make it use typeof.

But the same pattern is yet unfixed in a few more spots in the tests:
   tests/mq_sendrecv.c:198: .tv_sec = (time_t) 0xdeadfacebeeff00dLL,
   tests/mq_sendrecv.c:202: .tv_sec = (time_t) 0x7ea1fade7e57faceLL,
   tests/recvmmsg-timeout.c:60: ts->tv_sec = (time_t) 0xcafef00ddeadbeefLL;
   tests/xselect.c:216: tv_in.tv_sec = (time_t) 0xcafef00ddeadbeefLL;
   tests/xutimes.c:89: tv[1].tv_sec = (time_t) 0xcafef00ddeadbeefLL;

The first of them in build is in xselect and breaks the build via
../../tests/xselect.c: In function ‘main’:
../../tests/xselect.c:216:24: error: overflow in conversion from ‘long long int’ to ‘kernel_long_t’ {aka ‘long int’} changes value from ‘-3819351491602432273’ to ‘-559038737’ [-Werror=overflow]
  216 | tv_in.tv_sec = (time_t) 0xcafef00ddeadbeefLL;
      | ^

Without rewriting how time is handled there, and probably failing by not understanding enough of the intricacies of the program and the tests, how about just applying the same fix to the other cases that are left. Trying that as a first angle of attack ...

[1]: https://github.com/strace/strace/commit/891ab42b7015037520a01042201d4ddc548c266d
[2]: https://github.com/strace/strace/commit/7178658ead8ccfe196694dc5434f0f37db8746b4

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

It has not yet completed build, but seems to have passed the section it failed before.
Hence opening up for review:

PPA: https://launchpad.net/~paelzer/+archive/ubuntu/lp-2060805-time-t-conversions/+packages
MR: https://code.launchpad.net/~paelzer/ubuntu/+source/strace/+git/strace/+merge/464606

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Fix approved, submitted upstream to have a reference. I hope the lists accepts that without waiting for a moderator. If it takes too long I'll upload the fix to Ubuntu and mention the upstreaming ref later here.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Upstreamed via: https://lists.strace.io/pipermail/strace-devel/2024-April/011415.html

Updated patch header and uploaded

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Builds are all complete, waiting for tests to get run

Changed in strace:
status: New → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package strace - 6.8-0ubuntu2

---------------
strace (6.8-0ubuntu2) noble; urgency=medium

  * d/p/fix-time_t-conversion.patch: fix conversions to compile with
    64bit time_t (LP: #2060805)

strace (6.8-0ubuntu1) noble; urgency=medium

  * New upstream version to match kernel version.

 -- Christian Ehrhardt <email address hidden> Thu, 18 Apr 2024 11:32:42 +0200

Changed in strace (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.