Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions runtime/caml/backtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ CAMLextern void caml_print_exception_backtrace(void);
void caml_init_backtrace(void);
CAMLextern void caml_init_debug_info(void);

value caml_get_exception_raw_backtrace(value unit);

#endif /* CAML_INTERNALS */

#endif /* CAML_BACKTRACE_H */
24 changes: 16 additions & 8 deletions runtime/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,14 +1165,22 @@ static void domain_terminate(void);
static value make_finished(caml_result result)
{
CAMLparam0();
CAMLlocal1(res);
res = caml_alloc_1(
(caml_result_is_exception(result) ?
1 /* Error */ :
0 /* Ok */),
result.data);
/* [Finished res] */
res = caml_alloc_1(0, res);
CAMLlocal2(res, bt);
if (caml_result_is_exception(result)) {
res = result.data; /* Ensure that [result.data] is rooted before subsequent allocaitons */
bt = caml_get_exception_raw_backtrace(Val_unit);

res = caml_alloc_2(0, res, bt);
/* res = (exn, bt) */
res = caml_alloc_1(1 /* error */, res);
/* res = Error (exn, bt) */
res = caml_alloc_1(0 /* Finished */, res);
/* res = Finished (Error (exn, bt)) */
} else {
res = caml_alloc_1(0 /* ok */, result.data);
/* res = Ok v */
res = caml_alloc_1(0 /* Finished (Ok v) */, res);
}
CAMLreturn(res);
}

Expand Down
2 changes: 2 additions & 0 deletions stdlib/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ stdlib__Digest.cmi : digest.mli
stdlib__Domain.cmo : domain.ml \
stdlib__Sys.cmi \
stdlib.cmi \
stdlib__Printexc.cmi \
stdlib__Obj.cmi \
stdlib__Mutex.cmi \
stdlib__List.cmi \
Expand All @@ -226,6 +227,7 @@ stdlib__Domain.cmo : domain.ml \
stdlib__Domain.cmx : domain.ml \
stdlib__Sys.cmx \
stdlib.cmx \
stdlib__Printexc.cmx \
stdlib__Obj.cmx \
stdlib__Mutex.cmx \
stdlib__List.cmx \
Expand Down
2 changes: 1 addition & 1 deletion stdlib/StdlibModules
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ STDLIB_MODULE_BASENAMES = \
mutex \
condition \
semaphore \
domain \
camlinternalFormat \
printf \
arg \
printexc \
domain \
fun \
gc \
in_channel \
Expand Down
4 changes: 2 additions & 2 deletions stdlib/domain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module Raw = struct

type 'a state =
| Running
| Finished of ('a, exn) result [@warning "-unused-constructor"]
| Finished of ('a, exn * Printexc.raw_backtrace) result [@warning "-unused-constructor"]

type 'a term_sync = {
(* protected by [mut] *)
Expand Down Expand Up @@ -296,6 +296,6 @@ let join { term_sync ; _ } =
in
match Mutex.protect term_sync.mut loop with
| Ok x -> x
| Error ex -> raise ex
| Error (ex, bt) -> Printexc.raise_with_backtrace ex bt

let recommended_domain_count = Raw.get_recommended_domain_count
Loading