Skip to content

Commit

Permalink
Remove Cancel_hook_failed
Browse files Browse the repository at this point in the history
It's not used for anything and it breaks dscheck.
  • Loading branch information
talex5 committed Nov 8, 2023
1 parent bc1e231 commit cf4da1a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions lib_eio/core/cancel.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
exception Cancelled = Exn.Cancelled
exception Cancel_hook_failed = Exn.Cancel_hook_failed

type state =
| On
Expand Down Expand Up @@ -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 =
Expand Down
7 changes: 1 addition & 6 deletions lib_eio/core/eio__core.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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. *)
Expand Down
3 changes: 0 additions & 3 deletions lib_eio/core/exn.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib_eio/core/switch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit cf4da1a

Please sign in to comment.