-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `execve` action allocated the arrays in the forked child process. However, in a multi-threaded program we might have forked while another thread had the malloc lock. In that case, the child would wait forever because it inherited the locked mutex but not the thread that would unlock it. e.g. #0 futex_wait (private=0, expected=2, futex_word=0xffff9509cb10 <main_arena>) at ../sysdeps/nptl/futex-internal.h:146 #1 __GI___lll_lock_wait_private (futex=futex@entry=0xffff9509cb10 <main_arena>) at ./nptl/lowlevellock.c:34 #2 0x0000ffff94f8e780 in __libc_calloc (n=<optimized out>, elem_size=<optimized out>) at ./malloc/malloc.c:3650 #3 0x0000aaaac67cfa68 in make_string_array (errors=errors@entry=37, v_array=281472912006504) at fork_action.c:47 #4 0x0000aaaac67cfaf4 in action_execve (errors=37, v_config=281472912003024) at fork_action.c:61 #5 0x0000aaaac67cf93c in eio_unix_run_fork_actions (errors=errors@entry=37, v_actions=281472912002960) at fork_action.c:19
- Loading branch information
Showing
4 changed files
with
88 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
open Eio.Std | ||
|
||
let n_domains = 4 | ||
let n_rounds = 100 | ||
let n_procs_per_round = 100 | ||
let n_procs_per_round_per_domain = 100 / n_domains | ||
|
||
let main mgr = | ||
let run_in_domain mgr = | ||
let echo n = Eio.Process.parse_out mgr Eio.Buf_read.line ["sh"; "-c"; "echo " ^ string_of_int n] in | ||
Switch.run @@ fun sw -> | ||
for j = 1 to n_procs_per_round_per_domain do | ||
Fiber.fork ~sw (fun () -> | ||
let result = echo j in | ||
assert (int_of_string result = j); | ||
(* traceln "OK: %d" j *) | ||
) | ||
done | ||
|
||
let main ~dm mgr = | ||
let t0 = Unix.gettimeofday () in | ||
for i = 1 to n_rounds do | ||
Switch.run @@ fun sw -> | ||
for j = 1 to n_procs_per_round do | ||
Fiber.fork ~sw (fun () -> | ||
let result = echo j in | ||
assert (int_of_string result = j); | ||
(* traceln "OK: %d" j *) | ||
) | ||
done; | ||
if false then traceln "Finished round %d/%d" i n_rounds | ||
Switch.run (fun sw -> | ||
for _ = 1 to n_domains - 1 do | ||
Fiber.fork ~sw (fun () -> Eio.Domain_manager.run dm (fun () -> run_in_domain mgr)) | ||
done; | ||
Fiber.fork ~sw (fun () -> run_in_domain mgr); | ||
); | ||
if true then traceln "Finished round %d/%d" i n_rounds | ||
done; | ||
let t1 = Unix.gettimeofday () in | ||
let n_procs = n_rounds * n_procs_per_round in | ||
traceln "Finished process stress test: ran %d processes in %.2fs" n_procs (t1 -. t0) | ||
let n_procs = n_rounds * n_procs_per_round_per_domain * n_domains in | ||
traceln "Finished process stress test: ran %d processes in %.2fs (using %d domains)" n_procs (t1 -. t0) n_domains | ||
|
||
let () = | ||
Eio_main.run @@ fun env -> | ||
main env#process_mgr | ||
main ~dm:env#domain_mgr env#process_mgr |