Fix several multi-arch-related issues#530
Merged
wolfcw merged 2 commits intowolfcw:masterfrom Feb 1, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix ft_shared_time_s layout for cross-arch compatibility.
Fix replace semaphore with flock for cross-arch compatibility.