Fix FreeBSD test failures in POSIX implementation #160
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.
Summary
This PR fixes the FreeBSD-specific test failures reported in #156 after the initial FreeBSD support was merged.
Issues Fixed
Based on testing feedback from @cristian64:
Changes
1. Fix POSIX Semaphore Naming (Fixes 24 test failures)
Problem: FreeBSD requires POSIX semaphore names to start with "/", but the current implementation passed names without this prefix.
Solution:
clear_storage()to use the same naming conventionFile:
src/libipc/platform/posix/semaphore_impl.hCode changes:
2. Fix Robust Mutex EOWNERDEAD Handling (Fixes random crashes)
Problem: When
pthread_mutex_lock()returnsEOWNERDEAD, the previous implementation calledpthread_mutex_consistent()then immediatelypthread_mutex_unlock()and retried. This caused FreeBSD's libthr to detect inconsistent robust mutex list state, resulting in fatal errors:Root cause:
EOWNERDEADmeans the lock is already acquired by the calling threadpthread_mutex_consistent(), the mutex is in a consistent state and we hold the lockSolution:
pthread_mutex_consistent(), return success immediatelyFile:
src/libipc/platform/posix/mutex.hCode changes:
Testing
On Linux
On FreeBSD (needs verification)
Technical Notes
Why This Works
Semaphore naming:
EOWNERDEAD handling:
pthread_mutex_consistent()marks the mutex as consistent, but doesn't unlock itPlatform Differences
References
Checklist
Request for Testing
@cristian64 Could you please test this branch on your FreeBSD system? It should fix all the test failures you reported.
Expected results:
Closes #156