[infer][reporting] Adding boilerplate for reporting Activity leaks

master
Sam Blackshear 9 years ago
parent 2f7c957008
commit 66ef0ec0b9

@ -26,6 +26,10 @@ let hpred_is_open_resource prop = function
| _ -> | _ ->
None None
(** Produce a description of a persistent reference to an Android Activity *)
let explain_activity_leak activity_typ fieldname =
Localise.desc_activity_leak activity_typ fieldname
(** Explain a deallocate stack variable error *) (** Explain a deallocate stack variable error *)
let explain_deallocate_stack_var pvar ra = let explain_deallocate_stack_var pvar ra =
let pvar_str = pvar_to_string pvar in let pvar_str = pvar_to_string pvar in

@ -40,6 +40,9 @@ val find_boolean_assignment : Cfg.Node.t -> Sil.pvar -> bool -> Cfg.Node.t optio
(** describe rvalue [e] as a dexp *) (** describe rvalue [e] as a dexp *)
val exp_rv_dexp : Cfg.Node.t -> Sil.exp -> Sil.dexp option val exp_rv_dexp : Cfg.Node.t -> Sil.exp -> Sil.dexp option
(** Produce a description of a persistent reference to an Android Activity *)
val explain_activity_leak : Sil.typ -> Ident.fieldname -> Localise.error_desc
(** Produce a description of a mismatch between an allocation function and a deallocation function *) (** Produce a description of a mismatch between an allocation function and a deallocation function *)
val explain_allocation_mismatch : Sil.res_action -> Sil.res_action -> Localise.error_desc val explain_allocation_mismatch : Sil.res_action -> Sil.res_action -> Localise.error_desc

@ -30,6 +30,7 @@ type err_kind =
Kwarning | Kerror | Kinfo Kwarning | Kerror | Kinfo
exception Abduction_case_not_implemented of ml_location exception Abduction_case_not_implemented of ml_location
exception Activity_leak of Localise.error_desc * ml_location
exception Analysis_stops of Localise.error_desc * ml_location option exception Analysis_stops of Localise.error_desc * ml_location option
exception Array_out_of_bounds_l1 of Localise.error_desc * ml_location exception Array_out_of_bounds_l1 of Localise.error_desc * ml_location
exception Array_out_of_bounds_l2 of Localise.error_desc * ml_location exception Array_out_of_bounds_l2 of Localise.error_desc * ml_location
@ -87,6 +88,8 @@ let recognize_exception exn =
let err_name, desc, mloco, visibility, severity, force_kind, eclass = match exn with (* all the names of Exn_user errors must be defined in Localise *) let err_name, desc, mloco, visibility, severity, force_kind, eclass = match exn with (* all the names of Exn_user errors must be defined in Localise *)
| Abduction_case_not_implemented mloc -> | Abduction_case_not_implemented mloc ->
(Localise.from_string "Abduction_case_not_implemented", Localise.no_desc, Some mloc, Exn_developer, Low, None, Nocat) (Localise.from_string "Abduction_case_not_implemented", Localise.no_desc, Some mloc, Exn_developer, Low, None, Nocat)
| Activity_leak (desc, _) ->
(Localise.activity_leak, desc, None, Exn_user, High, None, Nocat)
| Analysis_stops (desc, mloco) -> | Analysis_stops (desc, mloco) ->
let visibility = if !Config.analysis_stops then Exn_user else Exn_developer in let visibility = if !Config.analysis_stops then Exn_user else Exn_developer in
(Localise.analysis_stops, desc, mloco, visibility, Medium, None, Nocat) (Localise.analysis_stops, desc, mloco, visibility, Medium, None, Nocat)

@ -30,6 +30,7 @@ type err_kind =
type err_class = Checker | Prover | Nocat type err_class = Checker | Prover | Nocat
exception Abduction_case_not_implemented of ml_location exception Abduction_case_not_implemented of ml_location
exception Activity_leak of Localise.error_desc * ml_location
exception Analysis_stops of Localise.error_desc * ml_location option exception Analysis_stops of Localise.error_desc * ml_location option
exception Array_of_pointsto of ml_location exception Array_of_pointsto of ml_location
exception Array_out_of_bounds_l1 of Localise.error_desc * ml_location exception Array_out_of_bounds_l1 of Localise.error_desc * ml_location

@ -28,6 +28,7 @@ let to_string s = s
(** compare two localised strings *) (** compare two localised strings *)
let compare (s1: string) (s2: string) = Pervasives.compare s1 s2 let compare (s1: string) (s2: string) = Pervasives.compare s1 s2
let activity_leak = "ACTIVITY_LEAK"
let analysis_stops = "ANALYSIS_STOPS" let analysis_stops = "ANALYSIS_STOPS"
let array_out_of_bounds_l1 = "ARRAY_OUT_OF_BOUNDS_L1" let array_out_of_bounds_l1 = "ARRAY_OUT_OF_BOUNDS_L1"
let array_out_of_bounds_l2 = "ARRAY_OUT_OF_BOUNDS_L2" let array_out_of_bounds_l2 = "ARRAY_OUT_OF_BOUNDS_L2"
@ -363,6 +364,11 @@ let java_unchecked_exn_desc proc_name exn_name pre_str : error_desc =
"can throw "^(Mangled.to_string exn_name); "can throw "^(Mangled.to_string exn_name);
"whenever "^pre_str], None, []) "whenever "^pre_str], None, [])
let desc_activity_leak activity_typ fieldname : error_desc =
let activity_str = Sil.typ_to_string activity_typ in
let fld_str = Ident.fieldname_to_string fieldname in
(["Activity subclass"; activity_str; "may leak via static field"; fld_str], None, [])
let desc_assertion_failure loc : error_desc = let desc_assertion_failure loc : error_desc =
(["could be raised"; at_line (Tags.create ()) loc], None, []) (["could be raised"; at_line (Tags.create ()) loc], None, [])

@ -25,6 +25,7 @@ val to_string : t -> string
(** compare two localised strings *) (** compare two localised strings *)
val compare : t -> t -> int val compare : t -> t -> int
val activity_leak : t
val analysis_stops : t val analysis_stops : t
val array_out_of_bounds_l1 : t val array_out_of_bounds_l1 : t
val array_out_of_bounds_l2 : t val array_out_of_bounds_l2 : t
@ -189,6 +190,8 @@ val desc_null_test_after_dereference : string -> int -> Sil.location -> error_de
val java_unchecked_exn_desc : Procname.t -> Mangled.t -> string -> error_desc val java_unchecked_exn_desc : Procname.t -> Mangled.t -> string -> error_desc
val desc_activity_leak : Sil.typ -> Ident.fieldname -> error_desc
(* Create human-readable error description for assertion failures *) (* Create human-readable error description for assertion failures *)
val desc_assertion_failure : Sil.location -> error_desc val desc_assertion_failure : Sil.location -> error_desc

Loading…
Cancel
Save