[infer][scheduler] always return None when the method is already being analyzed

Summary: This is to make sure than the analysis produces the same results independently from the order in which the members of a call cycle are analyzed.

Reviewed By: sblackshear, mbouaziz

Differential Revision: D6881971

fbshipit-source-id: 23872e1
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent 56872d8126
commit b4b901c725

@ -169,8 +169,10 @@ let run_proc_analysis analyze_proc ~caller_pdesc callee_pdesc =
let analyze_proc_desc ?caller_pdesc callee_pdesc = let analyze_proc_desc ?caller_pdesc callee_pdesc =
let cache = Lazy.force cached_results in
let callee_pname = Procdesc.get_proc_name callee_pdesc in let callee_pname = Procdesc.get_proc_name callee_pdesc in
if is_active callee_pname then None
else
let cache = Lazy.force cached_results in
try Typ.Procname.Hash.find cache callee_pname with Not_found -> try Typ.Procname.Hash.find cache callee_pname with Not_found ->
let summary_option = let summary_option =
let callbacks = Option.value_exn !callbacks_ref in let callbacks = Option.value_exn !callbacks_ref in
@ -179,13 +181,15 @@ let analyze_proc_desc ?caller_pdesc callee_pdesc =
Some (run_proc_analysis callbacks.analyze_ondemand ~caller_pdesc callee_pdesc) Some (run_proc_analysis callbacks.analyze_ondemand ~caller_pdesc callee_pdesc)
else Specs.get_summary callee_pname else Specs.get_summary callee_pname
in in
if not (is_active callee_pname) then Typ.Procname.Hash.add cache callee_pname summary_option ; Typ.Procname.Hash.add cache callee_pname summary_option ;
summary_option summary_option
(** analyze_proc_name curr_pdesc proc_name performs an on-demand analysis of proc_name triggered (** analyze_proc_name curr_pdesc proc_name performs an on-demand analysis of proc_name triggered
during the analysis of curr_pname *) during the analysis of curr_pname *)
let analyze_proc_name ?caller_pdesc callee_pname = let analyze_proc_name ?caller_pdesc callee_pname =
if is_active callee_pname then None
else
let cache = Lazy.force cached_results in let cache = Lazy.force cached_results in
try Typ.Procname.Hash.find cache callee_pname with Not_found -> try Typ.Procname.Hash.find cache callee_pname with Not_found ->
let summary_option = let summary_option =
@ -198,7 +202,7 @@ let analyze_proc_name ?caller_pdesc callee_pname =
Specs.get_summary callee_pname Specs.get_summary callee_pname
else Specs.get_summary callee_pname else Specs.get_summary callee_pname
in in
if not (is_active callee_pname) then Typ.Procname.Hash.add cache callee_pname summary_option ; Typ.Procname.Hash.add cache callee_pname summary_option ;
summary_option summary_option

@ -68,7 +68,6 @@ codetoanalyze/cpp/errors/npe/npe_added_to_b1.cpp, npe_added_to_b1::causes_npe, 2
codetoanalyze/cpp/errors/npe/npe_added_to_b1.cpp, npe_added_to_b1::causes_npe_person, 2, NULL_DEREFERENCE, [start of procedure npe_added_to_b1::causes_npe_person(),start of procedure Person,return from a call to npe_added_to_b1::Person_Person,start of procedure npe_added_to_b1::deref_person()] codetoanalyze/cpp/errors/npe/npe_added_to_b1.cpp, npe_added_to_b1::causes_npe_person, 2, NULL_DEREFERENCE, [start of procedure npe_added_to_b1::causes_npe_person(),start of procedure Person,return from a call to npe_added_to_b1::Person_Person,start of procedure npe_added_to_b1::deref_person()]
codetoanalyze/cpp/errors/npe/null_returned_by_method.cpp, testNullDeref, 3, NULL_DEREFERENCE, [start of procedure testNullDeref(),Condition is true,start of procedure getNull,return from a call to XFactory_getNull] codetoanalyze/cpp/errors/npe/null_returned_by_method.cpp, testNullDeref, 3, NULL_DEREFERENCE, [start of procedure testNullDeref(),Condition is true,start of procedure getNull,return from a call to XFactory_getNull]
codetoanalyze/cpp/errors/npe/object_deref.cpp, object_deref::derefNullField, 2, NULL_DEREFERENCE, [start of procedure object_deref::derefNullField(),start of procedure object_deref::getNull(),return from a call to object_deref::getNull] codetoanalyze/cpp/errors/npe/object_deref.cpp, object_deref::derefNullField, 2, NULL_DEREFERENCE, [start of procedure object_deref::derefNullField(),start of procedure object_deref::getNull(),return from a call to object_deref::getNull]
codetoanalyze/cpp/errors/npe/recursive_call.cpp, recursive_call::test_rec2_ok_FP, 2, PRECONDITION_NOT_MET, [start of procedure recursive_call::test_rec2_ok_FP(),start of procedure F,return from a call to recursive_call::F_F,start of procedure F,return from a call to recursive_call::F_F]
codetoanalyze/cpp/errors/npe/skip_function_with_const_formals.cpp, FP_const_skip2_then_split_case_ok, 5, MEMORY_LEAK, [start of procedure FP_const_skip2_then_split_case_ok(),Skipping skip_const2(): function or method not found,start of procedure test_pointer(),Condition is true,return from a call to test_pointer] codetoanalyze/cpp/errors/npe/skip_function_with_const_formals.cpp, FP_const_skip2_then_split_case_ok, 5, MEMORY_LEAK, [start of procedure FP_const_skip2_then_split_case_ok(),Skipping skip_const2(): function or method not found,start of procedure test_pointer(),Condition is true,return from a call to test_pointer]
codetoanalyze/cpp/errors/npe/skip_function_with_const_formals.cpp, FP_const_skip_then_split_case_ok, 6, MEMORY_LEAK, [start of procedure FP_const_skip_then_split_case_ok(),Skipping skip_const(): function or method not found,start of procedure test_pointer(),Condition is true,return from a call to test_pointer] codetoanalyze/cpp/errors/npe/skip_function_with_const_formals.cpp, FP_const_skip_then_split_case_ok, 6, MEMORY_LEAK, [start of procedure FP_const_skip_then_split_case_ok(),Skipping skip_const(): function or method not found,start of procedure test_pointer(),Condition is true,return from a call to test_pointer]
codetoanalyze/cpp/errors/npe/skip_function_with_const_formals.cpp, FP_typedef_skip_then_split_case_ok, 2, MEMORY_LEAK, [start of procedure FP_typedef_skip_then_split_case_ok(),Skipping skip_typedef(): function or method not found] codetoanalyze/cpp/errors/npe/skip_function_with_const_formals.cpp, FP_typedef_skip_then_split_case_ok, 2, MEMORY_LEAK, [start of procedure FP_typedef_skip_then_split_case_ok(),Skipping skip_typedef(): function or method not found]

@ -44,9 +44,9 @@ A* rec2(F f, A* a = nullptr) {
return a->getptr(); return a->getptr();
} }
int test_rec2_ok_FP() { int test_rec2_ok() {
F f; F f;
return rec2(f)->f; // PRECONDITION_NOT_MET return rec2(f)->f;
} }
} // namespace recursive_call } // namespace recursive_call

Loading…
Cancel
Save