From 2e7848b179c444fc73bc2886d3be4bcb6c09c39f Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Tue, 16 Jun 2020 03:11:24 -0700 Subject: [PATCH] [biabduction] Delete deallocate_stack_variable and deallocate_static_memory Summary: These issue types are unused, so let's delete them. Reviewed By: ngorogiannis Differential Revision: D22019490 fbshipit-source-id: 7834e04c9 --- infer/man/man1/infer-full.txt | 2 -- infer/man/man1/infer-report.txt | 2 -- infer/man/man1/infer.txt | 2 -- infer/src/absint/Localise.ml | 20 -------------------- infer/src/absint/Localise.mli | 4 ---- infer/src/base/IssueType.ml | 6 ------ infer/src/base/IssueType.mli | 4 ---- infer/src/biabduction/Exceptions.ml | 8 -------- infer/src/biabduction/Exceptions.mli | 4 ---- infer/src/biabduction/SymExec.ml | 21 +-------------------- infer/src/biabduction/errdesc.ml | 15 --------------- infer/src/biabduction/errdesc.mli | 6 ------ 12 files changed, 1 insertion(+), 93 deletions(-) diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index bdb5b8a9b..c74d4d7ae 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -410,8 +410,6 @@ OPTIONS DANGLING_POINTER_DEREFERENCE_MAYBE (disabled by default), DEADLOCK (enabled by default), DEAD_STORE (enabled by default), - DEALLOCATE_STACK_VARIABLE (enabled by default), - DEALLOCATE_STATIC_MEMORY (enabled by default), DIRECT_ATOMIC_PROPERTY_ACCESS (enabled by default), DISCOURAGED_WEAK_PROPERTY_CUSTOM_SETTER (enabled by default), DIVIDE_BY_ZERO (disabled by default), diff --git a/infer/man/man1/infer-report.txt b/infer/man/man1/infer-report.txt index 6c392af97..9d18332db 100644 --- a/infer/man/man1/infer-report.txt +++ b/infer/man/man1/infer-report.txt @@ -130,8 +130,6 @@ OPTIONS DANGLING_POINTER_DEREFERENCE_MAYBE (disabled by default), DEADLOCK (enabled by default), DEAD_STORE (enabled by default), - DEALLOCATE_STACK_VARIABLE (enabled by default), - DEALLOCATE_STATIC_MEMORY (enabled by default), DIRECT_ATOMIC_PROPERTY_ACCESS (enabled by default), DISCOURAGED_WEAK_PROPERTY_CUSTOM_SETTER (enabled by default), DIVIDE_BY_ZERO (disabled by default), diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 7017e8b8d..e5bebd4d8 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -410,8 +410,6 @@ OPTIONS DANGLING_POINTER_DEREFERENCE_MAYBE (disabled by default), DEADLOCK (enabled by default), DEAD_STORE (enabled by default), - DEALLOCATE_STACK_VARIABLE (enabled by default), - DEALLOCATE_STATIC_MEMORY (enabled by default), DIRECT_ATOMIC_PROPERTY_ACCESS (enabled by default), DISCOURAGED_WEAK_PROPERTY_CUSTOM_SETTER (enabled by default), DIVIDE_BY_ZERO (disabled by default), diff --git a/infer/src/absint/Localise.ml b/infer/src/absint/Localise.ml index f99b7f493..6a8a48de5 100644 --- a/infer/src/absint/Localise.ml +++ b/infer/src/absint/Localise.ml @@ -424,26 +424,6 @@ let desc_condition_always_true_false i cond_str_opt loc = {no_desc with descriptions= [description]; tags= !tags} -let desc_deallocate_stack_variable var_str proc_name loc = - let tags = Tags.create () in - Tags.update tags Tags.value var_str ; - let description = - Format.asprintf "Stack variable %a is freed by a %s" MF.pp_monospaced var_str - (call_to_at_line tags proc_name loc) - in - {no_desc with descriptions= [description]; tags= !tags} - - -let desc_deallocate_static_memory const_str proc_name loc = - let tags = Tags.create () in - Tags.update tags Tags.value const_str ; - let description = - Format.asprintf "Constant string %a is freed by a %s" MF.pp_monospaced const_str - (call_to_at_line tags proc_name loc) - in - {no_desc with descriptions= [description]; tags= !tags} - - let desc_class_cast_exception pname_opt typ_str1 typ_str2 exp_str_opt loc = let tags = Tags.create () in let in_expression = diff --git a/infer/src/absint/Localise.mli b/infer/src/absint/Localise.mli index 1c33dfa7f..351fe2889 100644 --- a/infer/src/absint/Localise.mli +++ b/infer/src/absint/Localise.mli @@ -105,10 +105,6 @@ val desc_class_cast_exception : val desc_condition_always_true_false : IntLit.t -> string option -> Location.t -> error_desc -val desc_deallocate_stack_variable : string -> Procname.t -> Location.t -> error_desc - -val desc_deallocate_static_memory : string -> Procname.t -> Location.t -> error_desc - val desc_divide_by_zero : string -> Location.t -> error_desc val desc_empty_vector_access : Procname.t option -> string -> Location.t -> error_desc diff --git a/infer/src/base/IssueType.ml b/infer/src/base/IssueType.ml index 5c8a52c0c..1b1833c1c 100644 --- a/infer/src/base/IssueType.ml +++ b/infer/src/base/IssueType.ml @@ -456,12 +456,6 @@ let deadlock = ~user_documentation:[%blob "../../documentation/issues/DEADLOCK.md"] -let deallocate_stack_variable = - register_from_string ~id:"DEALLOCATE_STACK_VARIABLE" Error Biabduction - - -let deallocate_static_memory = register_from_string ~id:"DEALLOCATE_STATIC_MEMORY" Error Biabduction - let _direct_atomic_property_access = register_from_string ~id:"DIRECT_ATOMIC_PROPERTY_ACCESS" Warning Linters ~user_documentation:[%blob "../../documentation/issues/DIRECT_ATOMIC_PROPERTY_ACCESS.md"] diff --git a/infer/src/base/IssueType.mli b/infer/src/base/IssueType.mli index 43b15b6e8..c9a45bcf1 100644 --- a/infer/src/base/IssueType.mli +++ b/infer/src/base/IssueType.mli @@ -168,10 +168,6 @@ val dead_store : t val deadlock : t -val deallocate_stack_variable : t - -val deallocate_static_memory : t - val divide_by_zero : t val do_not_report : t diff --git a/infer/src/biabduction/Exceptions.ml b/infer/src/biabduction/Exceptions.ml index 49dda43e5..d8dda7903 100644 --- a/infer/src/biabduction/Exceptions.ml +++ b/infer/src/biabduction/Exceptions.ml @@ -37,10 +37,6 @@ exception Custom_error of string * IssueType.severity * Localise.error_desc exception Dangling_pointer_dereference of bool (* is it user visible? *) * Localise.error_desc * L.ocaml_pos -exception Deallocate_stack_variable of Localise.error_desc - -exception Deallocate_static_memory of Localise.error_desc - exception Divide_by_zero of Localise.error_desc * L.ocaml_pos exception Empty_vector_access of Localise.error_desc * L.ocaml_pos @@ -133,10 +129,6 @@ let recognize_exception exn : IssueToReport.t = else IssueType.dangling_pointer_dereference_maybe in {issue_type; description= desc; ocaml_pos= Some ocaml_pos} - | Deallocate_stack_variable desc -> - {issue_type= IssueType.deallocate_stack_variable; description= desc; ocaml_pos= None} - | Deallocate_static_memory desc -> - {issue_type= IssueType.deallocate_static_memory; description= desc; ocaml_pos= None} | Divide_by_zero (desc, ocaml_pos) -> {issue_type= IssueType.divide_by_zero; description= desc; ocaml_pos= Some ocaml_pos} | Empty_vector_access (desc, ocaml_pos) -> diff --git a/infer/src/biabduction/Exceptions.mli b/infer/src/biabduction/Exceptions.mli index 9c3e6db14..fca2aba4d 100644 --- a/infer/src/biabduction/Exceptions.mli +++ b/infer/src/biabduction/Exceptions.mli @@ -36,10 +36,6 @@ exception Dangling_pointer_dereference of bool (* is it user visible? *) * Localise.error_desc * Logging.ocaml_pos -exception Deallocate_stack_variable of Localise.error_desc - -exception Deallocate_static_memory of Localise.error_desc - exception Divide_by_zero of Localise.error_desc * Logging.ocaml_pos exception Field_not_null_checked of Localise.error_desc * Logging.ocaml_pos diff --git a/infer/src/biabduction/SymExec.ml b/infer/src/biabduction/SymExec.ml index aeac12083..14c46f4a7 100644 --- a/infer/src/biabduction/SymExec.ml +++ b/infer/src/biabduction/SymExec.ml @@ -481,25 +481,6 @@ let check_already_dereferenced {InterproceduralAnalysis.proc_desc; err_log; tenv () -(** Check whether symbolic execution de-allocated a stack variable or a constant string, raising an - exception in that case *) -let check_deallocate_static_memory prop_after = - let check_deallocated_attribute = function - | Predicates.Apred (Aresource ({ra_kind= Rrelease} as ra), [Lvar pv]) - when Pvar.is_local pv || Pvar.is_global pv -> - let freed_desc = Errdesc.explain_deallocate_stack_var pv ra in - raise (Exceptions.Deallocate_stack_variable freed_desc) - | Predicates.Apred (Aresource ({ra_kind= Rrelease} as ra), [Const (Cstr s)]) -> - let freed_desc = Errdesc.explain_deallocate_constant_string s ra in - raise (Exceptions.Deallocate_static_memory freed_desc) - | _ -> - () - in - let exp_att_list = Attribute.get_all prop_after in - List.iter ~f:check_deallocated_attribute exp_att_list ; - prop_after - - let method_exists right_proc_name methods = if Language.curr_language_is Java then List.exists ~f:(fun meth_name -> Procname.equal right_proc_name meth_name) methods @@ -1915,7 +1896,7 @@ and sym_exec_wrapper ({InterproceduralAnalysis.tenv; _} as analysis_data) handle (* but force them into either branch *) p' | _ -> - check_deallocate_static_memory (Abs.abstract_junk analysis_data p') + Abs.abstract_junk analysis_data p' in L.d_str "Instruction " ; Sil.d_instr instr ; diff --git a/infer/src/biabduction/errdesc.ml b/infer/src/biabduction/errdesc.ml index 172e1fa02..34af389fe 100644 --- a/infer/src/biabduction/errdesc.ml +++ b/infer/src/biabduction/errdesc.ml @@ -55,21 +55,6 @@ let hpred_is_open_resource tenv prop = function None -(** Explain a deallocate stack variable error *) -let explain_deallocate_stack_var pvar ra = - let pvar_str = Pvar.to_string pvar in - Localise.desc_deallocate_stack_variable pvar_str ra.PredSymb.ra_pname ra.PredSymb.ra_loc - - -(** Explain a deallocate constant string error *) -let explain_deallocate_constant_string s ra = - let const_str = - let pp fmt = Exp.pp fmt (Exp.Const (Const.Cstr s)) in - F.asprintf "%t" pp - in - Localise.desc_deallocate_static_memory const_str ra.PredSymb.ra_pname ra.PredSymb.ra_loc - - let verbose = Config.trace_error (** Special case for C++, where we translate code like [struct X; X getX() { X x; return X; }] as diff --git a/infer/src/biabduction/errdesc.mli b/infer/src/biabduction/errdesc.mli index ca04a9b33..1c2283b8e 100644 --- a/infer/src/biabduction/errdesc.mli +++ b/infer/src/biabduction/errdesc.mli @@ -38,12 +38,6 @@ val explain_class_cast_exception : -> Localise.error_desc (** explain a class cast exception *) -val explain_deallocate_stack_var : Pvar.t -> PredSymb.res_action -> Localise.error_desc -(** Explain a deallocate stack variable error *) - -val explain_deallocate_constant_string : string -> PredSymb.res_action -> Localise.error_desc -(** Explain a deallocate constant string error *) - val explain_dereference : Procname.t -> Tenv.t