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:
Marcello Seri 2017-01-24 16:42:42 +00:00 committed by Simon Cruanes
parent 56462a862b
commit 59208fd9c6

View file

@ -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