mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
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).
This commit is contained in:
parent
0046bea415
commit
b50c9f4027
1 changed files with 3 additions and 4 deletions
|
|
@ -53,14 +53,13 @@ let release m t =
|
|||
*)
|
||||
|
||||
let with_acquire ~n t ~f =
|
||||
Mutex.lock t.mutex;
|
||||
acquire_once_locked_ n t;
|
||||
acquire n t;
|
||||
try
|
||||
let x = f() in
|
||||
release_once_locked_ n t;
|
||||
release n t;
|
||||
x
|
||||
with e ->
|
||||
release_once_locked_ n t;
|
||||
release n t;
|
||||
raise e
|
||||
|
||||
(*$R
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue