<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Improve Memory Allocation Backtraces when Reporting Errors."
   href="https://bugs.llvm.org/show_bug.cgi?id=39639">39639</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Improve Memory Allocation Backtraces when Reporting Errors.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>swestrup@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21113" name="attach_21113" title="Clang Static Analysis Report on jpegdump.c">attachment 21113</a> <a href="attachment.cgi?id=21113&action=edit" title="Clang Static Analysis Report on jpegdump.c">[details]</a></span>
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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>