From 902514dccd66d1758b22adb1de8a963c70b707bd Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Wed, 1 Apr 2020 03:40:01 -0700 Subject: [PATCH] [pulse] Add unreachable point to the trace of memory leaks Summary: When looking at some reports I realised that adding the place where the memory becomes unreachable to the trace makes it more readable. Reviewed By: skcho Differential Revision: D20790277 fbshipit-source-id: d5df69e68 --- infer/src/pulse/PulseDiagnostic.ml | 4 ++-- infer/tests/codetoanalyze/c/pulse/issues.exp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/infer/src/pulse/PulseDiagnostic.ml b/infer/src/pulse/PulseDiagnostic.ml index 307ead84a..16fad52a7 100644 --- a/infer/src/pulse/PulseDiagnostic.ml +++ b/infer/src/pulse/PulseDiagnostic.ml @@ -110,13 +110,13 @@ let get_trace = function ~pp_immediate:(fun fmt -> F.pp_print_string fmt "invalid access occurs here") access_trace @@ [] - | MemoryLeak {allocation_trace} -> + | MemoryLeak {location; allocation_trace} -> let access_start_location = Trace.get_start_location allocation_trace in add_errlog_header ~title:"allocation part of the trace starts here" access_start_location @@ Trace.add_to_errlog ~nesting:0 ~pp_immediate:(fun fmt -> F.pp_print_string fmt "allocation occurs here") allocation_trace - @@ [] + @@ [Errlog.make_trace_element 0 location "memory becomes unreachable here" []] | StackVariableAddressEscape {history; location; _} -> ValueHistory.add_to_errlog ~nesting:0 history @@ diff --git a/infer/tests/codetoanalyze/c/pulse/issues.exp b/infer/tests/codetoanalyze/c/pulse/issues.exp index 92634d016..f4adfb381 100644 --- a/infer/tests/codetoanalyze/c/pulse/issues.exp +++ b/infer/tests/codetoanalyze/c/pulse/issues.exp @@ -1,3 +1,3 @@ -codetoanalyze/c/pulse/memory_leak.c, malloc_interproc_no_free_bad, 0, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,when calling `create_p` here,allocation occurs here] -codetoanalyze/c/pulse/memory_leak.c, malloc_interproc_no_free_bad2, 4, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,allocation occurs here] -codetoanalyze/c/pulse/memory_leak.c, malloc_no_free_bad, 0, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,allocation occurs here] +codetoanalyze/c/pulse/memory_leak.c, malloc_interproc_no_free_bad, 0, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,when calling `create_p` here,allocation occurs here,memory becomes unreachable here] +codetoanalyze/c/pulse/memory_leak.c, malloc_interproc_no_free_bad2, 4, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,allocation occurs here,memory becomes unreachable here] +codetoanalyze/c/pulse/memory_leak.c, malloc_no_free_bad, 0, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,allocation occurs here,memory becomes unreachable here]