Compare commits

...

2 Commits

Author SHA1 Message Date
Thomas Leonard
9537ca1810
Merge pull request #640 from talex5/cancel-exn
Remove Cancel_hook_failed
2023-11-09 19:57:37 +00:00
Thomas Leonard
cf4da1a369 Remove Cancel_hook_failed
It's not used for anything and it breaks dscheck.
2023-11-08 13:55:56 +00:00
5 changed files with 10 additions and 15 deletions

View File

@ -76,10 +76,10 @@ They are run against whichever backend `Eio_main.run` selects, and therefore mus
`lib_eio/tests` tests some internal data structures, such as the lock-free cells abstraction.
The `.md` files in that directory provide a simple walk-through to demonstrate the basic operation,
while `lib_eio/tests/dscheck` uses [dscheck][] to perform exhaustive testing of all atomic interleavings
while `lib_eio/tests/dscheck` uses [dscheck][] to perform exhaustive testing of all atomic interleavings.
At the time of writing, dscheck has some performance problems that make it unusable by default, so
you must use the version in https://github.com/ocaml-multicore/dscheck/pull/3 instead.
you must use the version in https://github.com/ocaml-multicore/dscheck/pull/22 instead.
### Benchmarks

View File

@ -1,5 +1,4 @@
exception Cancelled = Exn.Cancelled
exception Cancel_hook_failed = Exn.Cancel_hook_failed
type state =
| On
@ -156,12 +155,16 @@ let cancel t ex =
x.cancel_fn <- ignore;
match fn cex with
| () -> aux xs
| exception ex2 -> ex2 :: aux xs
| exception ex2 ->
let bt = Printexc.get_raw_backtrace () in
(ex2, bt) :: aux xs
in
if fibers <> [] then (
match aux fibers with
| [] -> ()
| exns -> raise (Cancel_hook_failed exns)
| ex :: exs ->
let ex, bt = List.fold_left Exn.combine ex exs in
Printexc.raise_with_backtrace ex bt
)
let sub fn =

View File

@ -526,9 +526,6 @@ module Cancel : sig
The nested exception is only intended for debug-level logging and should generally be ignored. *)
exception Cancel_hook_failed of exn list
(** Raised by {!cancel} if any of the cancellation hooks themselves fail. *)
val sub : (t -> 'a) -> 'a
(** [sub fn] installs a new cancellation context [t], runs [fn t] inside it, and then restores the old context.
@ -561,9 +558,7 @@ module Cancel : sig
If [t] is already cancelled then this does nothing.
Note that the caller of this function is still responsible for handling the error somehow
(e.g. reporting it to the user); it does not become the responsibility of the cancelled thread(s).
@raise Cancel_hook_failed if one or more hooks fail. *)
(e.g. reporting it to the user); it does not become the responsibility of the cancelled thread(s). *)
val dump : t Fmt.t
(** Show the cancellation sub-tree rooted at [t], for debugging. *)

View File

@ -16,8 +16,6 @@ type err += Multiple_io of (err * context * Printexc.raw_backtrace) list
exception Cancelled of exn
exception Cancel_hook_failed of exn list
let create err = Io (err, { steps = [] })
let add_context ex fmt =
@ -90,7 +88,6 @@ let () =
Printexc.register_printer @@ function
| Io _ as ex -> Some (Fmt.str "@[<v>%a@]" pp ex)
| Multiple exns -> Some (Fmt.str "%a" pp_multiple exns)
| Cancel_hook_failed exns -> Some ("During cancellation:\n" ^ String.concat "\nand\n" (List.map Printexc.to_string exns))
| Cancelled ex -> Some ("Cancelled: " ^ Printexc.to_string ex)
| _ -> None

View File

@ -55,7 +55,7 @@ let fail ?(bt=Printexc.get_raw_backtrace ()) t ex =
t.exs <- Some (combine_exn (ex, bt) t.exs);
try
Cancel.cancel t.cancel ex
with Exn.Cancel_hook_failed _ as ex ->
with ex ->
let bt = Printexc.get_raw_backtrace () in
t.exs <- Some (combine_exn (ex, bt) t.exs)