Skip to content

Commit

Permalink
Merge pull request ocaml-multicore#779 from talex5/fork-bt
Browse files Browse the repository at this point in the history
Preserve backtraces in fork_daemon and fork_promise_exn
  • Loading branch information
talex5 authored Nov 16, 2024
2 parents eb8fe3e + 61f738d commit 9b939ab
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib_eio/core/fiber.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ let fork_daemon ~sw f =
(* The daemon was cancelled because all non-daemon fibers are finished. *)
()
| exception ex ->
Switch.fail sw ex; (* The [with_daemon] ensures this will succeed *)
let bt = Printexc.get_raw_backtrace () in
Switch.fail ~bt sw ex; (* The [with_daemon] ensures this will succeed *)
) (* else the fiber should report the error to [sw], but [sw] is failed anyway *)

let fork_promise ~sw f =
Expand All @@ -65,7 +66,8 @@ let fork_promise_exn ~sw f =
match Switch.with_op sw f with
| x -> Promise.resolve r x
| exception ex ->
Switch.fail sw ex (* The [with_op] ensures this will succeed *)
let bt = Printexc.get_raw_backtrace () in
Switch.fail ~bt sw ex (* The [with_op] ensures this will succeed *)
);
p

Expand Down

0 comments on commit 9b939ab

Please sign in to comment.