Package: faketime Version: 0.9.7-1 Severity: important Tags: patch The faketime package fails to work correctly on the Alpha architecture. This failure of faketime to work correctly is the reason for the mbedtls FTBFS, which uses faketime in its test suite [1].
Consider the following test program (which I call "time-test"): #include <stdio.h> #include <sys/time.h> #include <unistd.h> int main(void) { struct timeval tv; for (int j=0; j<5; j++) { usleep(10000); gettimeofday(&tv, NULL); printf("s=%ld us=%ld\n", tv.tv_sec, tv.tv_usec); } return 0; } When run it produces output like: s=1519025990 us=838219 s=1519025990 us=848965 s=1519025990 us=859711 s=1519025990 us=870456 s=1519025990 us=881202 But when run as (with faketime built in its source directory): LD_PRELOAD=faketime-0.9.7/src/libfaketime.so.1 FAKETIME="-1d" ./time-test the output is: s=2199023743604 us=0 s=2199023657204 us=0 s=2199023570804 us=0 s=2199023484404 us=0 s=2199023398004 us=0 which is definitely not correct. The reason for the incorrect behaviour is that there are two gettimeofday symbols in libc on Alpha and the dlsym() call to link to the gettimeofday() is picking up the function with the wrong ABI. I attach a patch to fix that. Faketime built with the attached patch works correctly and with a fixed faketime the mbedtls source package builds to completion on Alpha. Cheers Michael. [1] https://buildd.debian.org/status/fetch.php?pkg=mbedtls&arch=alpha&ver=2.7.0-2&stamp=1518727161&raw=0 -- System Information: Debian Release: buster/sid APT prefers unreleased APT policy: (500, 'unreleased'), (500, 'unstable') Architecture: alpha Kernel: Linux 4.14.10-titan-p1+ (SMP w/3 CPU cores) Locale: LANG=en_NZ.UTF-8, LC_CTYPE=en_NZ.UTF-8 (charmap=UTF-8), LANGUAGE=en_NZ.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init)
Index: faketime-0.9.7/src/libfaketime.c =================================================================== --- faketime-0.9.7.orig/src/libfaketime.c 2018-02-19 07:57:52.000000000 +1300 +++ faketime-0.9.7/src/libfaketime.c 2018-02-19 08:23:51.592643229 +1300 @@ -1658,7 +1658,11 @@ real_lstat64 = dlsym(RTLD_NEXT, "__lxstat64"); real_time = dlsym(RTLD_NEXT, "time"); real_ftime = dlsym(RTLD_NEXT, "ftime"); +#if defined(__alpha__) && defined(__GLIBC__) + real_gettimeofday = dlvsym(RTLD_NEXT, "gettimeofday", "GLIBC_2.1"); +#else real_gettimeofday = dlsym(RTLD_NEXT, "gettimeofday"); +#endif #ifdef FAKE_SLEEP real_nanosleep = dlsym(RTLD_NEXT, "nanosleep"); real_usleep = dlsym(RTLD_NEXT, "usleep"); @@ -1671,7 +1675,11 @@ #endif #ifdef FAKE_INTERNAL_CALLS real___ftime = dlsym(RTLD_NEXT, "__ftime"); +# if defined(__alpha__) && defined(__GLIBC__) + real___gettimeofday = dlvsym(RTLD_NEXT, "__gettimeofday", "GLIBC_2.1"); +# else real___gettimeofday = dlsym(RTLD_NEXT, "__gettimeofday"); +# endif real___clock_gettime = dlsym(RTLD_NEXT, "__clock_gettime"); #endif #ifdef __APPLEOSX__