Commit Graph

632 Commits

Author SHA1 Message Date
Wolfgang Hommel
6714b98794 Preparations for v0.9.11 release v0.9.11 2025-05-25 10:00:14 +02:00
Wolfgang Hommel
3e56ada3ff Merge pull request #495 from PiotrBzdrega/master
missing FUTEX_CLOCK_REALTIME declaration when build with flags -DINTERCEPT_SYSCALL -DINTERCEPT_FUTEX
2025-05-24 13:03:01 +02:00
PiotrBzdrega
2dca058f5c missing FUTEX_CLOCK_REALTIME declaration when build with flags -DINTERCEPT_SYSCALL -DINTERCEPT_FUTEX 2025-05-13 15:01:47 +02:00
Wolfgang Hommel
2e2d3eefb5 Merge pull request #493 from totoroyyb/master
[DRAFT] fix: unhandled futex-related syscall
2025-03-29 11:37:26 +01:00
Yibo Yan
fa731ed50f fix: unhandled futex wait syscall 2025-03-26 21:02:47 +00:00
Wolfgang Hommel
3f6467d421 Test different Ubuntu versions 2025-01-29 17:36:42 +01:00
Wolfgang Hommel
2dac72caba Test different Ubuntu versions 2025-01-29 17:21:51 +01:00
Wolfgang Hommel
21af5175f5 pthread.h on macOS 2025-01-28 21:30:17 +01:00
Wolfgang Hommel
b5a48c870b Merge pull request #488 from ijackson/races
Fix several data races
2025-01-28 19:59:24 +01:00
Wolfgang Hommel
52fe3cc442 Merge pull request #487 from ijackson/t64
Fake 64-bit time on 32-bit systems
2025-01-28 06:26:19 +01:00
Wolfgang Hommel
63aef51102 Merge pull request #486 from ijackson/utime
Re-disable faking utime by default
2025-01-28 06:24:32 +01:00
Ian Jackson
50e2c56914 Don't use _try_ locking calls for monotonic_conds_lock
This reverts commit 8ef74e33b6
   "Swapped out pthread_rwlock_xxlock() ..."

This could result in concurrent uses of pthread_cond_* erroneously
returning EAGAIN, which is not permitted by the spec and which the
application way well treat as a bug.  This seems to be happening in
gem2deb in ci.debian.net.

The commit message in 8ef74e33b6 says (rewrapped)

    Swapped out pthread_rwlock_xxlock(), which doesn't return if it
    can't obtain the lock, with pthread_rwlock_xxtrylock() followed by
    sched yield and error code return. The issue is sometimes a thread
    calling pthread_cond_init() or pthread_cond_destroy() can't
    acquire the lock when another thread is waiting on a condition
    variable notification via pthread_cond_timedwait(), and thus the
    thread calling pthread_cond_init() or pthread_cond_destroy() end
    up hanging indefinitely.

I don't think this is true.  The things that are done with
monotonic_conds_lock held are HASH_ADD_PTR HASH_FIND_PTR etc. on
monotonic_conds, which should all be fast and AFAICT don't in turn
take any locks.  So it shouldn't deadlock.

I conjecture that the underlying bug being experienced by the author
of "Swapped out pthread_rwlock_xxlock" was the lack of ftpl_init - ie,
access to an uninitialised pthread_rwlock_t.  That might result in a
hang.
2025-01-27 13:12:45 +00:00
Ian Jackson
b6e87c6f26 Call ftpl_init before using monotonic_conds_lock
Otherwise we can use this in an uninitialised state, which is not
allowed.

We call ftpl_init in pthread_cond_init_232, but the application might
not have called that.  For example, it might have a static condition
variable set up with PTHREAD_COND_INITIALIZER.
2025-01-27 13:12:45 +00:00
Ian Jackson
d9ba684b18 Replace data race with use of pthread_once (ft_shm_init) 2025-01-27 13:12:45 +00:00
Ian Jackson
2503b0fffc Replace data race with use of pthread_once (ftpl_init)
At the cost of no longer nicely detecting recursive initialisation
problems.

Fixes Debian bug #1093599
2025-01-27 13:12:38 +00:00
Ian Jackson
97721e5491 Interpose gettimeofday64 2025-01-27 12:27:03 +00:00
Ian Jackson
fdb5ba3f7a Interpose __time64 2025-01-27 12:27:03 +00:00
Ian Jackson
f289bf702f Fix interposition of clock_gettime64
timespec.tv_nsec is 32-bit, even though timeval.tv_usec is
64-bit (weirdly).  This doesn't matter very much in practice because
 * on little endian architectures (which is all our 32-bit release
   arches) writing to a too big integer ends up writing the
   desired value in the desired location, and
 * it doesn't affect the overall struct size on any of our actual
   architectures (which align the uint64_t to 8 so must make the
   whole struct 16 not 12), so the write overflow is harmless.

> #include <time.h>
> #include <sys/time.h>
> #include <stdio.h>
> struct timeval tv;
> struct timespec ts;
> int main(void) {
>    printf("time_t %lld\n", (unsigned long long) sizeof(time_t));
>    printf("timeval %lld %lld %lld\n",
>           (unsigned long long) sizeof(tv),
>           (unsigned long long) sizeof(tv.tv_sec),
>           (unsigned long long) sizeof(tv.tv_usec)
>           );
>    printf("timespec %lld %lld %lld\n",
>           (unsigned long long) sizeof(ts),
>           (unsigned long long) sizeof(ts.tv_sec),
>           (unsigned long long) sizeof(ts.tv_nsec)
>           );
> }
> (sid_armhf-dchroot)iwj@amdahl:~/Faketime/test$ gcc t.c
> (sid_armhf-dchroot)iwj@amdahl:~/Faketime/test$ ./a.out
> time_t 8
> timeval 16 8 8
> timespec 16 8 4
> (sid_armhf-dchroot)iwj@amdahl:~/Faketime/test$
2025-01-27 12:27:03 +00:00
Helge Deller
536889d797 Interpose clock_gettime64
Since debian generally added 64-bit time support on 32-bit
arches, now glibc sometimes calls the clock_gettime64 syscall
(and library wrapper).  This function was missing, and is added here.

Patch originally supplied here
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1064555
2025-01-27 12:26:40 +00:00
Ian Jackson
19b2476534 Re-disable faking utime by default
Fixes
  https://github.com/wolfcw/libfaketime/issues/483

See also
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1093412#35
Hopefully this will fix Debian #1093412.
2025-01-27 12:22:48 +00:00
Wolfgang Hommel
92c322507c Merge pull request #485 from LocutusOfBorg/master
test/libmallocintercept.c: fix write function unused return value
2025-01-25 13:04:34 +01:00
Gianfranco Costamagna
0516055224 test/libmallocintercept.c: fix write function unused return value
We should ignore the return value for logging function, to fix a new gcc ftbfs
libmallocintercept.c: In function ‘print_msg’:
libmallocintercept.c:27:9: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
   27 |         write(0, msg, strlen(msg));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
2025-01-22 12:22:37 +01:00
Wolfgang Hommel
ba9ed5b289 Merge pull request #473 from EgnalZurc/patch-1
Preventing shared semaphore to be used again
2024-06-05 19:52:44 +02:00
Egnal Zurc
7e9d69b98f Preventing shared sem to be used again
The shared semaphore is closed but it's not assigned to null.
That's required because the logic check the semaphore status if it's not null. For this reason, we are getting a core some times.
2024-06-05 12:16:41 +02:00
Wolfgang Hommel
a04750217b ft_dlvsym() check for NULL version 2024-03-24 21:08:36 +01:00
Wolfgang Hommel
a3e91605ad Merge pull request #463 from Rob--W/issue-130-dlsym
Add FAKETIME_IGNORE_SYMBOLS to skip unneeded dlsym
2024-03-19 19:43:22 +01:00
Wolfgang Hommel
b716122cbe Merge pull request #465 from Rob--W/add-disable-shm-option
Add --disable-shm / FAKETIME_DISABLE_SHM
2024-03-19 19:15:38 +01:00
Wolfgang Hommel
23bec3882d Merge pull request #466 from joshuataylor/feature/macos-arm64
Check if the user is on ARM64, add target to CFLAGS/LDFLAGS
2024-03-18 19:26:16 +01:00
Josh Taylor
2a2af0fcdc Check if the user is on ARM64, add target to CFLAGS/LDFLAGS 2024-03-18 13:48:26 +08:00
Rob Wu
39fdbde365 Add --disable-shm / FAKETIME_DISABLE_SHM
The use of shared memory has side effects. Currently, the only way to
opt out of shared memory is by compiling with -DFAKE_STATELESS.

To allow disabling shared memory without recompiling, this patch
introduces the --disable-shm option to `faketime`, equivalent to
setting the `FAKETIME_DISABLE_SHM=1` environment variable.
2024-03-13 00:02:08 +01:00
Rob Wu
c745ab783b Add FAKETIME_IGNORE_SYMBOLS to skip unneeded dlsym 2024-03-12 02:40:56 +01:00
Wolfgang Hommel
f32986867a Merge pull request #453 from martinetd/musl
fix build on recent musl (stat64 compat)
2024-01-18 06:22:33 +01:00
Dominique Martinet
b2fe742aa7 fix build on recent musl (stat64 compat)
musl removed LFS64 compat[1] so stat64 is no longer defined by default,
but we can bring it back for now through _LARGEFILE64_SOURCE

Link: https://www.openwall.com/lists/musl/2022/09/26/1 [1]
Fixes: #446
2024-01-18 12:47:41 +09:00
Wolfgang Hommel
265651969b Merge pull request #451 from RCoeurjoly/master
sycall also watches the timestamp_file
2024-01-02 15:14:05 +01:00
Roland Coeurjoly
6a0f35dcbd sycall also watches the timestamp_file 2024-01-02 15:09:12 +01:00
Wolfgang Hommel
0af80dd593 Merge pull request #435 from kraj/master
Makefile: Detect compiler in makefile
2023-08-25 11:50:32 +02:00
Khem Raj
8908752a25 Makefile: Detect compiler in makefile
Add compiler specific options based on detected compiler gcc/clang
2023-08-24 10:09:53 -07:00
Wolfgang Hommel
27b9c83a27 Merge pull request #434 from sliquister/master
adding support for faking statx
2023-08-01 07:35:14 +02:00
Valentin Gatien-Baron
942b30e940 adding support for faking statx 2023-07-30 20:55:48 -04:00
Wolfgang Hommel
7154a3f42c Set FAKETIME_FLSHM=1 to auto-unset FAKETIME_SHARED (addresses #427) 2023-06-08 13:12:39 +02:00
Wolfgang Hommel
0c2e3d41be the missing else branch on CLOCK_MONOTONIC in clock_nanosleep (#426) 2023-06-06 20:10:31 +02:00
Wolfgang Hommel
f262b5fba7 Re-check fake_monotonic_setting in clock_nanosleep (#426) 2023-06-06 19:48:18 +02:00
Wolfgang Hommel
d17bb114c6 Honor fake_monotoic_clock setting in clock_nanosleep, addresses #426 2023-06-04 13:21:09 +02:00
Wolfgang Hommel
7df1bf7122 Fix #424 2023-04-30 20:26:07 +02:00
Wolfgang Hommel
6d072025c0 Merge pull request #422 from fixindan/dead_lock_no_return
Swapped out pthread_rwlock_xxlock(), which doesn't return if it can't…
2023-02-25 12:58:03 +01:00
Dixin Fan
8ef74e33b6 Swapped out pthread_rwlock_xxlock(), which doesn't return if it can't obtain the lock, with pthread_rwlock_xxtrylock() followed by sched yield and error code return. The issue is sometimes a thread calling pthread_cond_init() or pthread_cond_destroy() can't acquire the lock when another thread is waiting on a condition variable notification via pthread_cond_timedwait(), and thus the thread calling pthread_cond_init() or pthread_cond_destroy() end up hanging indefinitely. 2023-02-24 16:18:47 -06:00
Wolfgang Hommel
6fc4ae74f4 Merge pull request #416 from sliquister/master
ensure faketime can't be initialized more than once
2023-01-27 20:43:41 +01:00
Valentin Gatien-Baron
1997652d8e ensure faketime can't be initialized more than once
One callsite of ftpl_init wasn't protected by the "if (!initialized)"
condition, specifically:

static void ftpl_init (void) __attribute__ ((constructor));

If another "constructor" was called before this one, and that other
constructor used time or filesystem functions, ftlp_init would be
initialized by that other constructor, and then reinitialized by the
ftpl_init constructor. At that point, confusion ensues.
2023-01-16 21:26:39 -05:00
Wolfgang Hommel
de37190d40 Merge pull request #415 from usertam/master
libfaketime.c: wrap timespec_get in TIME_UTC macro
2022-12-20 19:25:59 +01:00
Samuel Tam
e0e6b79568 libfaketime.c: wrap timespec_get in TIME_UTC macro
Function `timespec_get` is not guaranteed to be declared in MacOS
since its standard library is non-conformance to modern standards.
Therefore, skip patching `timespec_get` if it is undeclared by the
standard library.

The detection of `timespec_get` is based on the conjecture that the
macro `TIME_UTC` is only defined when `timespec_get` is declared.
2022-12-20 02:08:45 +08:00