Skip to content

Commit 59208fd

Browse files
mseric-cube
authored andcommitted
Fix with_acquire: release a non locked mutex is UB
This is segfaulting (on ubuntu 16.04 and 16.10) when trying to release the unlocked mutex in the release stage (in general this is an undefined behavior).
1 parent 56462a8 commit 59208fd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/threads/CCSemaphore.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,13 @@ let release m t =
5353
*)
5454

5555
let with_acquire ~n t ~f =
56-
Mutex.lock t.mutex;
57-
acquire_once_locked_ n t;
56+
acquire n t;
5857
try
5958
let x = f() in
60-
release_once_locked_ n t;
59+
release n t;
6160
x
6261
with e ->
63-
release_once_locked_ n t;
62+
release n t;
6463
raise e
6564

6665
(*$R

0 commit comments

Comments
 (0)