[absint] do not log restart scheduler exceptions

Summary:
These exceptions were caught earlier before but D21257474 made absint
log an error every time before reraising them.

The exception type had to move to IR/ or absint/, so I moved
"SchedulerTypes" to "absint/TaskSchedulerTypes" and added the restart
scheduler's exception there. There is already a "Scheduler.ml" file in
absint/ so to address the ambiguity I added "Task" in front of that one.

Reviewed By: ngorogiannis

Differential Revision: D21348593

fbshipit-source-id: 58055c9b7
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent c07e578539
commit de47214bcd

@ -304,9 +304,16 @@ module AbstractInterpreterCommon (TransferFunctions : NodeTransferFunctions) = s
| Ok post -> | Ok post ->
post post
| Error (exn, backtrace, instr) -> | Error (exn, backtrace, instr) ->
if not !logged_error then ( ( match exn with
L.internal_error "In instruction %a@\n" (Sil.pp_instr ~print_types:true Pp.text) instr ; | TaskSchedulerTypes.ProcnameAlreadyLocked _ ->
logged_error := true ) ; (* this isn't an error; don't log it *)
()
| _ ->
if not !logged_error then (
L.internal_error "In instruction %a@\n"
(Sil.pp_instr ~print_types:true Pp.text)
instr ;
logged_error := true ) ) ;
Caml.Printexc.raise_with_backtrace exn backtrace Caml.Printexc.raise_with_backtrace exn backtrace
in in
(* hack to ensure that we call `exec_instr` on a node even if it has no instructions *) (* hack to ensure that we call `exec_instr` on a node even if it has no instructions *)

@ -6,4 +6,8 @@
*) *)
open! IStd open! IStd
exception ProcnameAlreadyLocked of Procname.t
(** for the Restart scheduler: raise when a worker tries to analyze a procedure already being
analyzed by another process *)
type target = Procname of Procname.t | File of SourceFile.t type target = Procname of Procname.t | File of SourceFile.t

@ -7,7 +7,7 @@
open! IStd open! IStd
let make sources = let make sources =
let open SchedulerTypes in let open TaskSchedulerTypes in
let gen = let gen =
List.rev_map sources ~f:(fun sf -> File sf) List.rev_map sources ~f:(fun sf -> File sf)
|> List.permute ~random_state:(Random.State.make (Array.create ~len:1 0)) |> List.permute ~random_state:(Random.State.make (Array.create ~len:1 0))

@ -6,4 +6,4 @@
*) *)
open! IStd open! IStd
val make : SourceFile.t list -> (SchedulerTypes.target, Procname.t) ProcessPool.TaskGenerator.t val make : SourceFile.t list -> (TaskSchedulerTypes.target, Procname.t) ProcessPool.TaskGenerator.t

@ -19,7 +19,7 @@ let clear_caches_except_lrus () =
let clear_caches () = Ondemand.LocalCache.clear () ; clear_caches_except_lrus () let clear_caches () = Ondemand.LocalCache.clear () ; clear_caches_except_lrus ()
let analyze_target : (SchedulerTypes.target, Procname.t) Tasks.doer = let analyze_target : (TaskSchedulerTypes.target, Procname.t) Tasks.doer =
let analyze_source_file exe_env source_file = let analyze_source_file exe_env source_file =
if Topl.is_active () then DB.Results_dir.init (Topl.sourcefile ()) ; if Topl.is_active () then DB.Results_dir.init (Topl.sourcefile ()) ;
DB.Results_dir.init source_file ; DB.Results_dir.init source_file ;
@ -30,7 +30,7 @@ let analyze_target : (SchedulerTypes.target, Procname.t) Tasks.doer =
DotCfg.emit_frontend_cfg (Topl.sourcefile ()) (Topl.cfg ()) ; DotCfg.emit_frontend_cfg (Topl.sourcefile ()) (Topl.cfg ()) ;
if Config.write_html then Printer.write_all_html_files source_file ; if Config.write_html then Printer.write_all_html_files source_file ;
None None
with RestartScheduler.ProcnameAlreadyLocked pname -> Some pname ) with TaskSchedulerTypes.ProcnameAlreadyLocked pname -> Some pname )
in in
(* In call-graph scheduling, log progress every [per_procedure_logging_granularity] procedures. (* In call-graph scheduling, log progress every [per_procedure_logging_granularity] procedures.
The default roughly reflects the average number of procedures in a C++ file. *) The default roughly reflects the average number of procedures in a C++ file. *)
@ -46,7 +46,7 @@ let analyze_target : (SchedulerTypes.target, Procname.t) Tasks.doer =
try try
Ondemand.analyze_proc_name_toplevel exe_env proc_name ; Ondemand.analyze_proc_name_toplevel exe_env proc_name ;
None None
with RestartScheduler.ProcnameAlreadyLocked pname -> Some pname with TaskSchedulerTypes.ProcnameAlreadyLocked pname -> Some pname
in in
fun target -> fun target ->
let exe_env = Exe_env.mk () in let exe_env = Exe_env.mk () in
@ -124,7 +124,9 @@ let tasks_generator_builder_for sources =
let analyze source_files_to_analyze = let analyze source_files_to_analyze =
if Int.equal Config.jobs 1 then ( if Int.equal Config.jobs 1 then (
let target_files = List.rev_map source_files_to_analyze ~f:(fun sf -> SchedulerTypes.File sf) in let target_files =
List.rev_map source_files_to_analyze ~f:(fun sf -> TaskSchedulerTypes.File sf)
in
Tasks.run_sequentially ~f:analyze_target target_files ; Tasks.run_sequentially ~f:analyze_target target_files ;
BackendStats.get () ) BackendStats.get () )
else ( else (

@ -7,9 +7,7 @@
open! IStd open! IStd
module L = Logging module L = Logging
exception ProcnameAlreadyLocked of Procname.t type work_with_dependency = {work: TaskSchedulerTypes.target; need_to_finish: Procname.t option}
type work_with_dependency = {work: SchedulerTypes.target; need_to_finish: Procname.t option}
let of_list (lst : work_with_dependency list) : ('a, Procname.t) ProcessPool.TaskGenerator.t = let of_list (lst : work_with_dependency list) : ('a, Procname.t) ProcessPool.TaskGenerator.t =
let content = Queue.of_list lst in let content = Queue.of_list lst in
@ -39,10 +37,10 @@ let make sources =
List.map sources ~f:SourceFiles.proc_names_of_source List.map sources ~f:SourceFiles.proc_names_of_source
|> List.concat |> List.concat
|> List.rev_map ~f:(fun procname -> |> List.rev_map ~f:(fun procname ->
{work= SchedulerTypes.Procname procname; need_to_finish= None} ) {work= TaskSchedulerTypes.Procname procname; need_to_finish= None} )
in in
let files = let files =
List.map sources ~f:(fun file -> {work= SchedulerTypes.File file; need_to_finish= None}) List.map sources ~f:(fun file -> {work= TaskSchedulerTypes.File file; need_to_finish= None})
in in
let permute = List.permute ~random_state:(Random.State.make (Array.create ~len:1 0)) in let permute = List.permute ~random_state:(Random.State.make (Array.create ~len:1 0)) in
permute pnames @ permute files |> of_list permute pnames @ permute files |> of_list
@ -91,7 +89,7 @@ let lock_exn pname =
if ProcLocker.try_lock pname then record_locked_proc pname if ProcLocker.try_lock pname then record_locked_proc pname
else ( else (
unlock_all () ; unlock_all () ;
raise (ProcnameAlreadyLocked pname) ) ) raise (TaskSchedulerTypes.ProcnameAlreadyLocked pname) ) )
let unlock pname = let unlock pname =

@ -6,8 +6,6 @@
*) *)
open! IStd open! IStd
exception ProcnameAlreadyLocked of Procname.t
val setup : unit -> unit val setup : unit -> unit
val clean : unit -> unit val clean : unit -> unit
@ -16,4 +14,4 @@ val lock_exn : Procname.t -> unit
val unlock : Procname.t -> unit val unlock : Procname.t -> unit
val make : SourceFile.t list -> (SchedulerTypes.target, Procname.t) ProcessPool.TaskGenerator.t val make : SourceFile.t list -> (TaskSchedulerTypes.target, Procname.t) ProcessPool.TaskGenerator.t

@ -96,8 +96,8 @@ let build_from_sources sources =
g g
let bottom_up sources : (SchedulerTypes.target, Procname.t) ProcessPool.TaskGenerator.t = let bottom_up sources : (TaskSchedulerTypes.target, Procname.t) ProcessPool.TaskGenerator.t =
let open SchedulerTypes in let open TaskSchedulerTypes in
let syntactic_call_graph = build_from_sources sources in let syntactic_call_graph = build_from_sources sources in
let remaining = ref (CallGraph.n_procs syntactic_call_graph) in let remaining = ref (CallGraph.n_procs syntactic_call_graph) in
let remaining_tasks () = !remaining in let remaining_tasks () = !remaining in

@ -6,7 +6,7 @@
*) *)
open! IStd open! IStd
val make : SourceFile.t list -> (SchedulerTypes.target, Procname.t) ProcessPool.TaskGenerator.t val make : SourceFile.t list -> (TaskSchedulerTypes.target, Procname.t) ProcessPool.TaskGenerator.t
(** task generator that works by (** task generator that works by
- loading the syntactic call graph from the capture DB - loading the syntactic call graph from the capture DB

@ -223,7 +223,7 @@ let run_proc_analysis ~caller_pdesc callee_pdesc =
let backtrace = Printexc.get_backtrace () in let backtrace = Printexc.get_backtrace () in
IExn.reraise_if exn ~f:(fun () -> IExn.reraise_if exn ~f:(fun () ->
match exn with match exn with
| RestartScheduler.ProcnameAlreadyLocked _ -> | TaskSchedulerTypes.ProcnameAlreadyLocked _ ->
clear_actives () ; restore_global_state old_state ; true clear_actives () ; restore_global_state old_state ; true
| _ -> | _ ->
if not !logged_error then ( if not !logged_error then (

Loading…
Cancel
Save