-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This means that an exception is raised when attempting to lock a mutex locked from the same thread, e.g. from an asynchronous callback. This changes the behaviour on Windows where mutexes were recursive. Add test for deadlock inside asynchronous callbacks.
- Loading branch information
Showing
7 changed files
with
133 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(* TEST | ||
* hassysthreads | ||
include systhreads | ||
** bytecode | ||
** native | ||
*) | ||
|
||
let m = Mutex.create () | ||
|
||
let on = ref true | ||
|
||
let create_finalised () = | ||
let r = ref 0 in | ||
Gc.finalise (fun _ -> if !on then begin | ||
Mutex.lock m ; | ||
print_endline "finalised!" ; | ||
Mutex.unlock m | ||
end) r; | ||
r | ||
|
||
let () = | ||
print_endline "start" ; | ||
begin | ||
try | ||
while true do | ||
Mutex.lock m ; | ||
let x = create_finalised () in | ||
Mutex.unlock m ; | ||
ignore (Sys.opaque_identity x) | ||
done | ||
with | ||
e -> (on := false ; print_endline (Printexc.to_string e)) | ||
end; | ||
print_endline "end"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
start | ||
Sys_error("Mutex.lock: Resource deadlock avoided") | ||
end |