From 7e078b070b3acf6c0b24d66a150b09a7df57b09d Mon Sep 17 00:00:00 2001 From: Emilio Jesus Gallego Arias Date: Tue, 11 Feb 2020 11:33:55 +0100 Subject: [misc] Better preserve backtraces in several modules Re-raising inside exception handlers must be done with care in order to preserve backtraces; even if newer OCaml versions do a better job in automatically spilling `%reraise` in places that matter, there is no guarantee for that to happen. I've done a best-effort pass of places that were re-raising incorrectly, hopefully I got the logic right. There is the special case of `Nametab.error_global_not_found` which is raised many times in response to a `Not_found` error; IMHO this error should be converted to something more specific, however the scope of that change would be huge as to do easily... --- kernel/cbytegen.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'kernel') diff --git a/kernel/cbytegen.ml b/kernel/cbytegen.ml index 050f986367..b3a4bd7471 100644 --- a/kernel/cbytegen.ml +++ b/kernel/cbytegen.ml @@ -874,8 +874,11 @@ let compile ~fail_on_error ?universes:(universes=0) env c = (if !dump_bytecode then Feedback.msg_debug (dump_bytecodes init_code !fun_code fv)) ; Some (init_code,!fun_code, Array.of_list fv) - with TooLargeInductive msg -> - let fn = if fail_on_error then CErrors.user_err ?loc:None ~hdr:"compile" else + with TooLargeInductive msg as exn -> + let _, info = Exninfo.capture exn in + let fn = if fail_on_error then + CErrors.user_err ?loc:None ~info ~hdr:"compile" + else (fun x -> Feedback.msg_warning x) in fn msg; None -- cgit v1.2.3