Set timeouts handlers only in biabduction mode (#1391)

Summary:
Only register biabduction-style timeouts the first time the function
exe_timeout is called. This avoid getting timeouts in other
long-running analyses. (Especially on windows, where the wall clock is
used.)

Pull Request resolved: https://github.com/facebook/infer/pull/1391

Reviewed By: skcho

Differential Revision: D26780445

Pulled By: jvillard

fbshipit-source-id: 19631b702
master
Boris Yakobowski 4 years ago committed by Facebook GitHub Bot
parent 52447b01af
commit 05c25487f2

@ -76,19 +76,23 @@ let timeout_action _ =
raise (SymOp.Analysis_failure_exe FKtimeout) raise (SymOp.Analysis_failure_exe FKtimeout)
let () = let register_timeout_handlers =
(* Can't use Core since it wraps signal handlers and alarms with catch-all exception handlers that let already_registered = ref false in
exit, while we need to propagate the timeout exceptions. *) fun () ->
let module Gc = Caml.Gc in if not !already_registered then (
let module Sys = Caml.Sys in already_registered := true ;
match Config.os_type with (* Can't use Core since it wraps signal handlers and alarms with catch-all exception handlers
| Config.Unix | Config.Cygwin -> that exit, while we need to propagate the timeout exceptions. *)
Sys.set_signal Sys.sigvtalrm (Sys.Signal_handle timeout_action) ; let module Gc = Caml.Gc in
Sys.set_signal Sys.sigalrm (Sys.Signal_handle timeout_action) let module Sys = Caml.Sys in
| Config.Win32 -> match Config.os_type with
SymOp.set_wallclock_timeout_handler timeout_action ; | Config.Unix | Config.Cygwin ->
(* use the Gc alarm for periodic timeout checks *) Sys.set_signal Sys.sigvtalrm (Sys.Signal_handle timeout_action) ;
ignore (Gc.create_alarm SymOp.check_wallclock_alarm) Sys.set_signal Sys.sigalrm (Sys.Signal_handle timeout_action)
| Config.Win32 ->
SymOp.set_wallclock_timeout_handler timeout_action ;
(* use the Gc alarm for periodic timeout checks *)
ignore (Gc.create_alarm SymOp.check_wallclock_alarm) )
let unwind () = let unwind () =
@ -109,6 +113,7 @@ let resume_previous_timeout () =
let exe_timeout f x = let exe_timeout f x =
register_timeout_handlers () ;
let suspend_existing_timeout_and_start_new_one () = let suspend_existing_timeout_and_start_new_one () =
suspend_existing_timeout ~keep_symop_total:true ; suspend_existing_timeout ~keep_symop_total:true ;
Option.iter (SymOp.get_timeout_seconds ()) ~f:set_alarm ; Option.iter (SymOp.get_timeout_seconds ()) ~f:set_alarm ;

Loading…
Cancel
Save