Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Memprof: get rid of the idx_ptr pointers.
Instead, we use a thread-local variable [callback_status] which contains the index of the corresponding entry when a callback is running. We can do this since there can only be one running callback at the same time in a given thread. This lifts the restriction forbidding the call of Thread.exit from a memprof callback.
- Loading branch information
Showing
5 changed files
with
122 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
(* TEST | ||
modules = "thread_exit_in_callback_stub.c" | ||
exit_status = "42" | ||
* hassysthreads | ||
include systhreads | ||
** bytecode | ||
** native | ||
*) | ||
|
||
(* We cannot tell Ocamltest that this program is supposed to stop with | ||
a fatal error. Instead, we install a fatal error hook and call exit(42) *) | ||
external install_fatal_error_hook : unit -> unit = "install_fatal_error_hook" | ||
let _ = | ||
let main_thread = Thread.id (Thread.self ()) in | ||
Gc.Memprof.(start ~callstack_size:10 ~sampling_rate:1. | ||
{ null_tracker with alloc_minor = fun _ -> | ||
if Thread.id (Thread.self ()) <> main_thread then | ||
Thread.exit (); | ||
None }); | ||
let t = Thread.create (fun () -> | ||
ignore (Sys.opaque_identity (ref 1)); | ||
assert false) () | ||
in | ||
Thread.join t; | ||
Gc.Memprof.stop () | ||
|
||
let _ = | ||
install_fatal_error_hook (); | ||
Gc.Memprof.(start ~callstack_size:10 ~sampling_rate:1. | ||
{ null_tracker with alloc_minor = fun _ -> Thread.exit (); None }); | ||
ignore (Sys.opaque_identity (ref 1)) | ||
ignore (Sys.opaque_identity (ref 1)); | ||
assert false |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.