Package: libc0.1 Version: 2.24-14 Severity: normal Control: affects -1 src:ffmpeg
Hi, The clock() function on hurd has the wrong scaling factor. It generates only 100 clock ticks per second, even though CLOCKS_PER_SEC is 1000000. I has written a small testcase (attached) which illustrates the difference: amd64: CLOCKS_PER_SEC = 1000000 clock() = 444 sleeping for 1 second... clock() = 1000464 hurd-i386: CLOCKS_PER_SEC = 1000000 clock() = 0 sleeping for 1 second... clock() = 100 I raised this issue on debian-hurd here: https://lists.debian.org/debian-hurd/2017/07/msg00054.html While I appreciate that hurd's clock may not be able to be as precise as on Linux, but it should still return values which corresponds in some way to CLOCKS_PER_SEC. As far as I can tell, this bug is caused by the Debian patch: debian/patches/hurd-i386/unsubmitted-clock_t_centiseconds.diff The patch header contains a description about applications failing with high precision. IMHO those applications are broken. Their bugs should not be worked around in libc and that patch should be dropped. This was originally found after debugging ffmpeg. I believe the FTBFS on hurd is caused by this bug. Thanks, James
#include <time.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> static void busy_wait(int seconds) { struct timespec start, current; if (clock_gettime(CLOCK_MONOTONIC, &start) != 0) abort(); for (;;) { if (clock_gettime(CLOCK_MONOTONIC, ¤t) != 0) abort(); if (current.tv_sec - start.tv_sec > seconds || (current.tv_sec - start.tv_sec == seconds && current.tv_nsec >= start.tv_nsec)) break; } } int main(void) { printf("CLOCKS_PER_SEC = %ld\n", CLOCKS_PER_SEC); printf("clock() = %ld\n", clock()); printf("sleeping for 1 second...\n"); busy_wait(1); printf("clock() = %ld\n", clock()); return 0; }
signature.asc
Description: OpenPGP digital signature