Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce noise when OCaml exception tracking gets confused #301

Merged
Merged
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
29 changes: 23 additions & 6 deletions src/trace_writer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ type 'thread inner =
; trace : (module Trace with type thread = 'thread)
; annotate_inferred_start_times : bool
; mutable in_filtered_region : bool
; suppressed_errors : Hash_set.M(Source_code_position).t
}

type t = T : 'thread inner -> t
Expand All @@ -154,6 +155,13 @@ let sexp_of_inner inner =

let sexp_of_t (T inner) = sexp_of_inner inner

let eprint_s_once t here sexp =
if not (Hash_set.mem t.suppressed_errors here)
then (
Hash_set.add t.suppressed_errors here;
eprint_s sexp)
;;

let allocate_pid (type thread) (t : thread inner) ~name : int =
let module T = (val t.trace) in
T.allocate_pid ~name
Expand Down Expand Up @@ -312,6 +320,7 @@ let create_expert
; trace
; annotate_inferred_start_times
; in_filtered_region = true
; suppressed_errors = Hash_set.create (module Source_code_position)
}
in
write_hits t hits;
Expand Down Expand Up @@ -831,12 +840,20 @@ end = struct
some data. *)
if Callstack.depth thread_info.callstack <> 1
then
eprintf
"Warning: expected callstack depth to be the same going into a [try] \
block as when leaving it, but it wasn't (off by %d). Did Intel \
Processor Trace drop some data? Will attempt to recover.\n\
%!"
(Callstack.depth thread_info.callstack - 1)
(* Conditional on happening once, this is likely to happen again... don't
spam the user's terminal. *)
eprint_s_once
t
[%here]
[%message
"WARNING: expected callstack depth to be the same going into a \
[try] block as when leaving it, but it wasn't. Did Intel Processor \
Trace drop some data? Will attempt to recover. Further errors will \
be suppressed.\n"
~depth:(Callstack.depth thread_info.callstack - 1 : int)
(src : Event.Location.t)
(dst : Event.Location.t)
(last_known_instruction_pointer : Int64.Hex.t)]
else (
(* Only pop the exception callstack if we're at the same callstack
depth as we were when we saw [Pushtrap]. This should let us recover
Expand Down
Loading