Skip to content

Commit 8a2dba3

Browse files
committed
CA-409628: add missing Backtrace.is_important
This shows how brittle the current Backtrace API is, this was missing from a lot of places. We have some better alternatives (`with_backtraces`, or a `try_with` function) that'd guarantee that `important` is always called in the right place, but that would be a more invasive change, which will be done in a followup commit. Signed-off-by: Edwin Török <[email protected]>
1 parent eb5604b commit 8a2dba3

File tree

8 files changed

+11
-1
lines changed

8 files changed

+11
-1
lines changed

ocaml/gencert/selfcert.ml

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ let generate_pub_priv_key length =
109109
let stdout, _stderr = call_openssl args in
110110
Ok stdout
111111
with e ->
112+
Backtrace.is_important e ;
112113
let msg = "generating RSA key failed" in
113114
D.error "selfcert.ml: %s" msg ;
114115
Debug.log_backtrace e (Backtrace.get e) ;

ocaml/libs/http-lib/http_svr.ml

+1
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ let read_request ?proxy_seen ~read_timeout ~total_timeout ~max_length fd =
474474
in
475475
(Some r, proxy)
476476
with e ->
477+
Backtrace.is_important e ;
477478
D.warn "%s (%s)" (Printexc.to_string e) __LOC__ ;
478479
best_effort (fun () ->
479480
match e with

ocaml/libs/log/debug.ml

+4
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ let with_thread_associated ?client ?(quiet = false) desc f x =
258258
(* This function is a top-level exception handler typically used on fresh
259259
threads. This is the last chance to do something with the backtrace *)
260260
if not quiet then (
261+
(* It would seem that a Backtrace.is_important would be missing here.
262+
But in fact it has actually been called in [let result] above,
263+
so calling it again is not necessary.
264+
*)
261265
output_log "backtrace" Syslog.Err "error"
262266
(Printf.sprintf "%s failed with exception %s" desc
263267
(Printexc.to_string exn)

ocaml/xapi/cancel_tasks.ml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ open D
2121
let safe_wrapper n f x =
2222
try f x
2323
with e ->
24+
Backtrace.is_important e ;
2425
debug "Caught exception while cancelling tasks (%s): %s" n
2526
(ExnHelper.string_of_exn e) ;
2627
Debug.log_backtrace e (Backtrace.get e)

ocaml/xapi/storage_access.ml

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ let on_xapi_start ~__context =
162162
| Message_switch_failure ->
163163
[] (* no more logging *)
164164
| e ->
165+
Backtrace.is_important e ;
165166
error "Unexpected error querying the message switch: %s"
166167
(Printexc.to_string e) ;
167168
Debug.log_backtrace e (Backtrace.get e) ;

ocaml/xapi/xapi_extensions.ml

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ let call_extension rpc =
7979
| Api_errors.Server_error (code, params) ->
8080
API.response_of_failure code params
8181
| e ->
82+
Backtrace.is_important e ;
8283
error "Unexpected exception calling extension %s: %s" rpc.Rpc.name
8384
(Printexc.to_string e) ;
8485
Debug.log_backtrace e (Backtrace.get e) ;

ocaml/xapi/xapi_pool.ml

+1
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,7 @@ let create_or_get_secret_on_master __context rpc session_id (_secret_ref, secret
13581358
let protect_exn f x =
13591359
try Some (f x)
13601360
with e ->
1361+
Backtrace.is_important e ;
13611362
debug "Ignoring exception: %s" (Printexc.to_string e) ;
13621363
Debug.log_backtrace e (Backtrace.get e) ;
13631364
None

ocaml/xcp-rrdd/bin/rrdd/rrdd_server.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,10 @@ module Plugin = struct
692692
(* reset skip counts *)
693693
payload
694694
with e -> (
695+
Backtrace.is_important e ;
695696
incr_skip_count uid plugin ;
696697
(* increase skip count *)
697698
let log e =
698-
Backtrace.is_important e ;
699699
info "Failed to process plugin metrics file: %s (%s)"
700700
(P.string_of_uid ~uid) (Printexc.to_string e) ;
701701
log_backtrace e

0 commit comments

Comments
 (0)