https://bugs.llvm.org/show_bug.cgi?id=39639

            Bug ID: 39639
           Summary: Improve Memory Allocation Backtraces when Reporting
                    Errors.
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: dcough...@apple.com
          Reporter: swest...@gmail.com
                CC: dcough...@apple.com, llvm-bugs@lists.llvm.org

Created attachment 21113
  --> https://bugs.llvm.org/attachment.cgi?id=21113&action=edit
Clang Static Analysis Report on jpegdump.c

Recently when performing a scan-build on a large project, an uninitialized
pointer used as a parameter was reported on a function in a utility to dump the
structures of jpeg files. I'm attaching the report below.

The salient error is reported at line 659, but the routine that triggers the
bug is blameless, and there is no information there on the source of the bug.

If one looks at the place where the actual bug is, in the "load_images" routine
starting on line 1011, the trace information there is not only irrelevant, its
actaully misleading as to what the bug is.

The actual bug is that the variable nptr is being checked for null, (something
that should never happen in practice) and if it ever is, the allocation routine
aborts early without having allocated all of the entries it was meant to.
Removing the test for *nptr resolves the issue.

It would have helped immensely if the backtrace for load_images actually
mentioned the test for nptr and showed how it could cause an early exit from
the allocation routine. As is, the diagnostics were definitely unhelpful.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to