Commit 47fa303
committed
Fix segfault in EOWNERDEAD handling - remove incorrect ref count manipulation
Root cause: The previous code incorrectly called shm_->sub_ref() when handling
EOWNERDEAD, which could cause the shared memory to be freed prematurely while
the mutex pointer was still in use, leading to segmentation fault.
Fix: Remove the shm_->sub_ref() call. When EOWNERDEAD is returned, it means
we have successfully acquired the lock. We only need to call pthread_mutex_consistent()
to make the mutex usable again, then return success. The shared memory reference
count should not be modified in this path.
This fixes the segfault in MutexTest.TryLockExceptionSafety on FreeBSD 15.1 parent a82e3fa commit 47fa303
1 file changed
+8
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
210 | | - | |
211 | | - | |
| 209 | + | |
| 210 | + | |
212 | 211 | | |
213 | 212 | | |
214 | 213 | | |
215 | 214 | | |
216 | 215 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 216 | + | |
| 217 | + | |
222 | 218 | | |
223 | 219 | | |
224 | 220 | | |
| |||
238 | 234 | | |
239 | 235 | | |
240 | 236 | | |
241 | | - | |
242 | | - | |
243 | | - | |
| 237 | + | |
| 238 | + | |
244 | 239 | | |
245 | 240 | | |
246 | 241 | | |
247 | 242 | | |
248 | 243 | | |
249 | | - | |
| 244 | + | |
| 245 | + | |
250 | 246 | | |
251 | 247 | | |
252 | 248 | | |
| |||
0 commit comments