Skip to content

Commit 0a197fe

Browse files
jvillardfacebook-github-bot
authored andcommitted
[pulse] stop recording cycles after reporting them
Summary: Summary Cycles we already reported are of limited use and contribute to potential over-growth of cycles we keep track on in pathological cases. Reviewed By: ngorogiannis Differential Revision: D64545020 Privacy Context Container: L1208441 fbshipit-source-id: 8345ced36619b4aa3e23069751cc78388a7d91e5
1 parent f87c040 commit 0a197fe

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

infer/src/pulse/PulseAbductiveDomain.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ let add_missed_captures missed_captures ({transitive_info} as astate) =
21462146
let add_recursive_call location callee astate =
21472147
let trace = PulseMutualRecursion.mk location callee in
21482148
let recursive_calls = PulseMutualRecursion.Set.add trace astate.recursive_calls in
2149-
({astate with recursive_calls}, trace)
2149+
{astate with recursive_calls}
21502150
21512151
21522152
let add_recursive_calls traces astate =

infer/src/pulse/PulseAbductiveDomain.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ val finalize_all_hack_builders : t -> t
321321

322322
val mark_potential_leaks : Location.t -> dead_roots:Var.t list -> t -> t
323323

324-
val add_recursive_call : Location.t -> Procname.t -> t -> t * PulseMutualRecursion.t
324+
val add_recursive_call : Location.t -> Procname.t -> t -> t
325325

326326
val add_recursive_calls : PulseMutualRecursion.Set.t -> t -> t
327327

infer/src/pulse/PulseCallOperations.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,11 +633,12 @@ let maybe_dynamic_type_specialization_is_needed already_specialized contradictio
633633

634634
let on_recursive_call ({InterproceduralAnalysis.proc_desc} as analysis_data) call_loc callee_pname
635635
astate =
636-
let astate, cycle = AbductiveDomain.add_recursive_call call_loc callee_pname astate in
637-
if Procname.equal callee_pname (Procdesc.get_proc_name proc_desc) then
636+
if Procname.equal callee_pname (Procdesc.get_proc_name proc_desc) then (
638637
PulseReport.report analysis_data ~is_suppressed:false ~latent:false
639-
(MutualRecursionCycle {cycle; location= call_loc}) ;
640-
astate
638+
(MutualRecursionCycle
639+
{cycle= PulseMutualRecursion.mk call_loc callee_pname; location= call_loc} ) ;
640+
astate )
641+
else AbductiveDomain.add_recursive_call call_loc callee_pname astate
641642

642643

643644
let check_uninit_method ({InterproceduralAnalysis.tenv} as analysis_data) call_loc callee_pname

infer/src/pulse/PulseInterproc.ml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -963,24 +963,22 @@ let report_mutual_recursion_cycle
963963
if is_foreign_procedure then add_errlog inner_call err_log )
964964

965965

966-
let report_recursive_calls ({InterproceduralAnalysis.proc_desc} as analysis_data) cycles =
967-
PulseMutualRecursion.Set.iter
968-
(fun cycle ->
969-
if
970-
Procname.equal
971-
(PulseMutualRecursion.get_inner_call cycle)
972-
(Procdesc.get_proc_name proc_desc)
973-
then report_mutual_recursion_cycle analysis_data cycle )
974-
cycles
975-
976-
977-
let record_recursive_calls analysis_data callee_proc_name call_loc callee_summary call_state =
966+
let record_recursive_calls ({InterproceduralAnalysis.proc_desc} as analysis_data) callee_proc_name
967+
call_loc callee_summary call_state =
978968
let callee_recursive_calls =
979-
PulseMutualRecursion.Set.map
980-
(PulseMutualRecursion.add_call callee_proc_name call_loc)
969+
PulseMutualRecursion.Set.filter_map
970+
(fun cycle ->
971+
let cycle = PulseMutualRecursion.add_call callee_proc_name call_loc cycle in
972+
if
973+
Procname.equal
974+
(PulseMutualRecursion.get_inner_call cycle)
975+
(Procdesc.get_proc_name proc_desc)
976+
then (
977+
report_mutual_recursion_cycle analysis_data cycle ;
978+
None )
979+
else Some cycle )
981980
(AbductiveDomain.Summary.get_recursive_calls callee_summary)
982981
in
983-
report_recursive_calls analysis_data callee_recursive_calls ;
984982
let astate = AbductiveDomain.add_recursive_calls callee_recursive_calls call_state.astate in
985983
{call_state with astate}
986984

infer/tests/codetoanalyze/c/pulse/issues.exp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ codetoanalyze/c/pulse/specialization.c, add_more_bad, 2, MUTUAL_RECURSION_CYCLE,
180180
codetoanalyze/c/pulse/specialization.c, test_invoke_bad, 3, NULLPTR_DEREFERENCE, no_bucket, ERROR, [is assigned to the null pointer,assigned,invalid access occurs here]
181181
codetoanalyze/c/pulse/specialization.c, test_recursive_invoke_bad, 3, NULLPTR_DEREFERENCE, no_bucket, ERROR, [is assigned to the null pointer,assigned,invalid access occurs here]
182182
codetoanalyze/c/pulse/specialization.c, two_pointers_recursion_bad, 2, MUTUAL_RECURSION_CYCLE, no_bucket, WARNING, [`two_pointers_recursion_bad` makes a recursive call to `two_pointers_recursion_bad`]
183-
codetoanalyze/c/pulse/specialization.c, invoke_itself_bad, 3, MUTUAL_RECURSION_CYCLE, no_bucket, WARNING, [`invoke_itself_bad` calls `invoke_itself_bad`,`invoke_itself_bad` makes a recursive call to `invoke_itself_bad`]
184183
codetoanalyze/c/pulse/specialization.c, invoke_itself_bad, 3, MUTUAL_RECURSION_CYCLE, no_bucket, WARNING, [`invoke_itself_bad` makes a recursive call to `invoke_itself_bad`]
185184
codetoanalyze/c/pulse/taint_var_arg.c, printf_source_bad1, 0, TAINT_ERROR, no_bucket, ERROR, [source of the taint here: value returned from `int_source` with kind `Simple`,flows to this sink: value passed as argument `#2` to `printf` with kind `Simple`], source: int_source, sink: printf, tainted expression: int_source()
186185
codetoanalyze/c/pulse/taint_var_arg.c, printf_source_bad2, 1, TAINT_ERROR, no_bucket, ERROR, [source of the taint here: value returned from `int_source` with kind `Simple`,flows to this sink: value passed as argument `#2` to `printf` with kind `Simple`], source: int_source, sink: printf, tainted expression: int_source()

0 commit comments

Comments
 (0)