mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 19:55:31 -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
56462a862b
commit
59208fd9c6
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