Commit 543672b
committed
Fix FreeBSD-specific issues in POSIX implementation
This commit addresses the test failures reported in issue #156
on FreeBSD platform.
1. Fix POSIX semaphore naming for FreeBSD compatibility
- FreeBSD requires semaphore names to start with "/"
- Add "_sem" suffix to avoid namespace conflicts with shm
- Store semaphore name separately for proper cleanup
- This fixes all 24 semaphore test failures
2. Fix robust mutex EOWNERDEAD handling
- When pthread_mutex_lock returns EOWNERDEAD, the lock is
already acquired by the calling thread
- After calling pthread_mutex_consistent(), we should return
success immediately, not unlock and retry
- Previous behavior caused issues with FreeBSD's libthr robust
mutex list management, leading to fatal errors
- This fixes the random crashes in MutexTest
Technical details:
- EOWNERDEAD indicates the previous lock owner died while holding
the lock, but the current thread has successfully acquired it
- pthread_mutex_consistent() restores the mutex to a consistent state
- The Linux implementation worked differently, but the new approach
is more correct according to POSIX semantics and works on both
Linux and FreeBSD
Fixes #1561 parent 006a46e commit 543672b
2 files changed
+35
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
222 | 223 | | |
223 | | - | |
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 247 | + | |
253 | 248 | | |
| 249 | + | |
| 250 | + | |
254 | 251 | | |
255 | | - | |
256 | 252 | | |
257 | 253 | | |
258 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
42 | 50 | | |
43 | | - | |
| 51 | + | |
44 | 52 | | |
45 | 53 | | |
46 | 54 | | |
| |||
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
55 | | - | |
56 | | - | |
| 63 | + | |
57 | 64 | | |
58 | | - | |
59 | | - | |
| 65 | + | |
| 66 | + | |
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
| 70 | + | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
| |||
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
75 | 84 | | |
76 | 85 | | |
77 | 86 | | |
78 | 87 | | |
79 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
80 | 96 | | |
81 | 97 | | |
82 | 98 | | |
| |||
0 commit comments