Skip to content

Fix several multi-arch-related issues#530

Merged
wolfcw merged 2 commits intowolfcw:masterfrom
drolevar:fix_master
Feb 1, 2026
Merged

Fix several multi-arch-related issues#530
wolfcw merged 2 commits intowolfcw:masterfrom
drolevar:fix_master

Conversation

@drolevar
Copy link
Copy Markdown
Contributor

Fix ft_shared_time_s layout for cross-arch compatibility.
Fix replace semaphore with flock for cross-arch compatibility.

Replace struct timespec (arch-dependent long/time_t) with fixed-width
int64_t pairs in ft_shared_s so that 32-bit and 64-bit processes
interpret the same shared memory layout identically.

Fix ftruncate calls that allocated sizeof(uint64_t) (8 bytes) instead
of sizeof(struct ft_shared_s) (64-80 bytes) for the shared memory
region. Fix munmap in ft_cleanup using the wrong size.

Add struct layout test and cross-process shared memory functional test.
POSIX named semaphores (sem_t) have architecture-dependent internal
layout in glibc: 32 bytes on 64-bit, 16 bytes on 32-bit. When a
64-bit faketime wrapper creates a semaphore and spawns a 32-bit child,
the child misinterprets the counter and hangs on sem_wait forever.

Extract ft_sem_* abstraction into shared ft_sem.h/ft_sem.c with three
backends: FT_POSIX (existing), FT_SYSV (existing), FT_FLOCK (new
default). The flock backend uses kernel-mediated file locking on
/dev/shm/faketime_lock_<pid>, which is architecture-independent and
auto-releases on process death.

Both libfaketime.so and the faketime wrapper now use the same shared
abstraction, ensuring protocol agreement regardless of backend.
@wolfcw wolfcw self-assigned this Jan 27, 2026
@wolfcw wolfcw merged commit 3062fb2 into wolfcw:master Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants