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,9 +76,13 @@ let timeout_action _ =
raise (SymOp.Analysis_failure_exe FKtimeout)
let () =
(* Can't use Core since it wraps signal handlers and alarms with catch-all exception handlers that
exit, while we need to propagate the timeout exceptions. *)
let register_timeout_handlers =
let already_registered = ref false in
fun () ->
if not !already_registered then (
already_registered := true ;
(* Can't use Core since it wraps signal handlers and alarms with catch-all exception handlers
that exit, while we need to propagate the timeout exceptions. *)
let module Gc = Caml.Gc in
let module Sys = Caml.Sys in
match Config.os_type with
@ -88,7 +92,7 @@ let () =
| 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)
ignore (Gc.create_alarm SymOp.check_wallclock_alarm) )
let unwind () =
@ -109,6 +113,7 @@ let resume_previous_timeout () =
let exe_timeout f x =
register_timeout_handlers () ;
let suspend_existing_timeout_and_start_new_one () =
suspend_existing_timeout ~keep_symop_total:true ;
Option.iter (SymOp.get_timeout_seconds ()) ~f:set_alarm ;

Loading…
Cancel
Save