<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>Bratislava, Slovakia
$ szelethus@inf.elte.hu (K. Umann); gsd@inf.elte.hu (Z. Porkoláb)
 gsd.web.elte.hu (Z. Porkoláb)</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>A Case Study on the Quality of Static Analysis Bug Reports</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Kristóf Umann</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Zoltán Porkoláb</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>ELTE, Eötvös Lóránd University</institution>
          ,
          <addr-line>Budapest</addr-line>
          ,
          <country country="HU">Hungary.</country>
          <institution>Faculty of Informatics, Department of Programming Languages and Compilers</institution>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2023</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>Finding bugs in software using automated tools has enjoyed generous attention for as long as humans wrote software. With the increase in computing capacity and advancement in compiler theory, static analyzer tools like the Clang Static Analyzer have been an unexpandable part of several software development projects. The Clang Static Analyzer, like many other tools of its kind, employs heuristics, which may lead to reports on correct code - so-called false positives. The evaluation and the potential ifxing of the reports cannot be automated, requiring valuable time from the most expensive and least available resource during development, a human expert. While the finding of bugs stands in the focus of academic research, the intelligible presentation of those findings to the user was less frequently discussed. In our paper, we survey several reports emitted by the Clang Static Analyzer to understand what makes a bug report hard to understand. Our study aims to pave the way for further research to fix the problems discussed here.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;static analysis</kwd>
        <kwd>C</kwd>
        <kwd>C++</kwd>
        <kwd>Clang</kwd>
        <kwd>LLVM</kwd>
        <kwd>bug report quality</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Maintenance costs take a considerable chunk out of the budget of any development team. Most
of these expenses are spent fixing bugs. The earlier a bug is detected, the lower the cost of the
ifx [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]; therefore, alongside traditional methods of testing, it is worth pursuing automated tools,
such as static analyzers.
      </p>
      <p>
        Static analyzers provide early feedback on the quality of software by design. It is a popular
method for finding bugs and code smells, and various tools implement it [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. Many of the
applied techniques are fast and cheap enough to be integrated into the Continuous Integration
(CI) loops, therefore, they have a positive impact on the speeding up of development.
      </p>
      <p>
        Most static analysis methods apply heuristics, meaning they may often underestimate or
overestimate program behaviour [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]; in other words, static analysis trades precision for coverage. This
means that after the analysis, all reports must be inspected by a professional who has to decide
manually whether the report stands or is a false positive. This further strains what is usually the
most expensive and the least available resources. It has the utmost importance to maximize the
efectiveness of the step where humans are involved [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. As such, the communication between
the automated analysis tool and the user must be as smooth as possible.
      </p>
      <p>In this paper, we survey bug reports generated by the Clang Static Analyzer, inspect various
selected examples, and discuss where communication with the user is lacking. Alongside an
evaluation of how many reports are intelligible from the complete report set, we highlight two
specific faults observed in several reports.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Measurement methodology</title>
      <p>In this section, we discuss the way we approached surveying the Clang Static Analyzer’s reports.</p>
      <sec id="sec-2-1">
        <title>2.1. Briefly on how the analyzer works</title>
        <p>
          A decent simplified explanation of how symbolic execution [
          <xref ref-type="bibr" rid="ref5 ref6">5, 6</xref>
          ] works, which is the technique
used by the Clang Static Analyzer, would be the following. Suppose we have a C++ interpreter.
The interpreter’s input is the source code (written in one of the C family of languages). Starting
from the primary function, it reads and executes each statement one by one, sometimes by
jumping to another function. It keeps track of the values of variables (using symbolic [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], as
opposed to concrete values) and the call stack. If it encounters a condition, it splits the analysis
in two – one where the condition is assumed true and one where it is assumed false [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. Before
executing a statement, it allows various modules, or so-called “checkers”, to check preconditions,
and after the execution, it applies postconditions. If any of these conditions are violated, it emits
a warning for the user.
        </p>
        <p>
          The Clang Static Analyzer [
          <xref ref-type="bibr" rid="ref10 ref11 ref12 ref9">9, 10, 11, 12</xref>
          ] is an open-source tool that implements symbolic
execution on the C family of languages. Clang [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ], which encompasses the static analyzer, is
the primary compiler frontend for LLVM and has now enjoyed more than 15 years as one of
the leading static analyzers for C/C++. For the remainder of the paper, we refer to the Clang
Static Analyzer under the term analyzer.
        </p>
      </sec>
      <sec id="sec-2-2">
        <title>2.2. Our focus on the measurements</title>
        <p>Following the above analogy, the interpreter is the analyzer’s engine, and checkers define
pre- and postconditions. For instance, core.DivByZero defines that the denominator must
not be 0. If the engine can prove that the denominator is 0, a warning is emitted; otherwise,
it is assumed that it is non-zero. Some checkers implement more sophisticated semantics
– unix.MismatchedDeallocator keeps track of whether malloc() or operator new was
allocated some memory and whether the corresponding deallocator was used to release it.</p>
        <p>The former example is a checker that relies strongly on the correct operation of the engine.
While the latter example relies on the engine as well, its own bookkeeping is a large component
of its logic. For this reason, we chose to limit our investigations to core.DivByZero, because
we are more interested in the general mechanics and faults of bug report generation and less so
in reports on specific domains.
Acid
fmpeg
LLVM + Clang
OpenSSL
postgres
QTBase
Vim
Xerces
Total</p>
        <p>Total reports
1
6
11
1
2
7
2
1
31</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Results &amp; Discussion</title>
      <p>
        We tested the latest version of the analyzer1 on the following open-source C and C++ projects:
Acid [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], fmpeg [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ], LLVM and Clang [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ], OpenSSL [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ], postgres [
        <xref ref-type="bibr" rid="ref18">18</xref>
        ], QTBase [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ], vim [
        <xref ref-type="bibr" rid="ref20">20</xref>
        ]
and Xerces [
        <xref ref-type="bibr" rid="ref21">21</xref>
        ]. Combined, these projects cover a wide variety of coding techniques, codebase
sizes, and diferent versions of the languages’ standards.
      </p>
      <p>Table 1. partially summarizes our findings. We sorted the results we surveyed into the 3
categories:
• Acceptable: It is possible to understand the report, and whether it stands, even if it could
be improved.
• Not enough info: It is not possible understand the report, but it is possible to say which
function calls / value changes the analyzer neglected to explain, and a domain expert may
possess the missing information and judge whether the report stands.
• Incomprehensible: The entire bug report is incomprehensible, and its doubtful that even a
domain expert can judge the report.</p>
      <p>Overall, we found that out of 31 reports, 11 division by zero reports were not acceptable. Of
that, 6 reports were incomprehensible; 4 was reported in QTBase, and concerned code where
numerous integers and floating point numbers were used in a hard-to-follow manner. An
example is shown on Figure 1. For the other reports, it was more apparent that the analyzer
was at fault for failing to generate a proper report, rather than the source code being messy. We
feel that the analyzer was also the tool to blame for the reports that lacked more information.
An example for this case can be seen in Figure 2.</p>
      <p>Out of 31 reports, only 20 reports were at all acceptable. That is not to say that extracting the
necessary information was easy but at the very least possible. We identified a pattern of indirect
reasoning, shown in Figure 3. The example shows that i’s value is 0 when we assume it to be
equal to NumElts, which is why the division-by-zero warning occurs at the remainder operator.
1The latest version of Clang at of time of writing is 16.0.6.
While the example is only a few lines, we found that this indirect reasoning in other reports
is often spread over several function calls, several hundred lines of code, and several logical
statements that wear on the memory of the user. It would be easier to understand this report if
the warning stated “NumElts is known to be 0 because it is equal to i, which has a value of 0.”.</p>
      <p>
        Supporting findings of a previous research [
        <xref ref-type="bibr" rid="ref22">22</xref>
        ], we also identified that many of the leading
notes in the reports are superfluous. Of the acceptable reports, 6 reports had fewer than 10
notes, 8 had 10 to 19 notes, 6 had 20 or more notes. We measured how many notes we could
omit in sequence from the first note – we found that only the last few are usually important. Of
the acceptable reports, 11 reports had less than 10 meaningful notes, and the rest had fewer
than 20.
      </p>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion</title>
      <p>Symbolic execution, a static analysis technique, is a powerful tool to find deeply rooted
programming errors. Despite its strengths, it often emits bug reports that leave much to be desired,
demanding even more of the most expensive resource and least available in a software
development project: human experts.</p>
      <p>We surveyed a a popular static analyzer tool, the Clang Static Analyzer, that checks code of
the C family of languages with a complex technique called symbolic execution. We discussed
that it consists of an engine that interprets the code and several checkers defining programming
semantics. We took measurements of a checker that does relatively little modelling and relies
mainly on the engine and generalized bug reporting techniques.</p>
      <p>We found that out of 31 reports, 6 are incomprehensible, 5 do not contain enough information
to understand the finding, and 20 are acceptable, even if poor. We identified two specific
classes of problems: one where chains of logical statements need to be deciphered by the user
to understand the report, and one where only the last few notes of the report were actually
important.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>B.</given-names>
            <surname>Boehm</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V. R.</given-names>
            <surname>Basili</surname>
          </string-name>
          ,
          <source>Software defect reduction top 10 list, Computer</source>
          <volume>34</volume>
          (
          <year>2001</year>
          )
          <fpage>135</fpage>
          -
          <lpage>137</lpage>
          . URL: http://dx.doi.org/10.1109/2.962984. doi:
          <volume>10</volume>
          .1109/2.962984.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bessey</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Block</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Chelf</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Chou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Fulton</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Hallem</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Henri-Gros</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Kamsky</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>McPeak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Engler</surname>
          </string-name>
          ,
          <article-title>A few billion lines of code later: Using static analysis to find bugs in the real world</article-title>
          ,
          <source>Commun. ACM</source>
          <volume>53</volume>
          (
          <year>2010</year>
          )
          <fpage>66</fpage>
          -
          <lpage>75</lpage>
          . URL: http://doi.acm.
          <source>org/10</source>
          .1145/1646353. 1646374. doi:
          <volume>10</volume>
          .1145/1646353.1646374.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>M.</given-names>
            <surname>Anders</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I. S.</given-names>
            <surname>Michael</surname>
          </string-name>
          ,
          <article-title>Static program analysis</article-title>
          .,
          <year>2012</year>
          . URL: https://users-cs.au.dk/ amoeller/spa/spa.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>B.</given-names>
            <surname>Johnson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Song</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Murphy-Hill</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Bowdidge</surname>
          </string-name>
          ,
          <article-title>Why don't software developers use static analysis tools to find bugs?</article-title>
          ,
          <source>in: 2013 35th International Conference on Software Engineering (ICSE)</source>
          ,
          <year>2013</year>
          , pp.
          <fpage>672</fpage>
          -
          <lpage>681</lpage>
          . doi:
          <volume>10</volume>
          .1109/ICSE.
          <year>2013</year>
          .
          <volume>6606613</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>C.</given-names>
            <surname>Szabó</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kotul</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Petruš</surname>
          </string-name>
          ,
          <article-title>A closer look at software refactoring using symbolic execution</article-title>
          ,
          <source>in: Proceedings of the 9th International Conference on Applied Informatics</source>
          , Volume
          <volume>2</volume>
          ,
          <string-name>
            <given-names>Eszterházy</given-names>
            <surname>Károly</surname>
          </string-name>
          College,
          <year>2015</year>
          . URL: https://doi.org/10.14794%
          <issue>2Ficai</issue>
          .
          <fpage>9</fpage>
          .
          <year>2014</year>
          .
          <volume>2</volume>
          . 309. doi:
          <volume>10</volume>
          .14794/icai.9.
          <year>2014</year>
          .
          <volume>2</volume>
          .309.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>E.</given-names>
            <surname>Fülöp</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Pataki</surname>
          </string-name>
          ,
          <article-title>A DSL for resource checking using finite state automaton-driven symbolic execution</article-title>
          ,
          <source>Open Computer Science</source>
          <volume>11</volume>
          (
          <year>2020</year>
          )
          <fpage>107</fpage>
          -
          <lpage>115</lpage>
          . URL: https://doi.org/10. 1515%
          <fpage>2Fcomp</fpage>
          -2020-0120. doi:
          <volume>10</volume>
          .1515/comp-2020-0120.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Xu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Kremenek</surname>
          </string-name>
          ,
          <string-name>
            <surname>J. Zhang,</surname>
          </string-name>
          <article-title>A memory model for static analysis of C programs (</article-title>
          <year>2010</year>
          )
          <fpage>535</fpage>
          -
          <lpage>548</lpage>
          . URL: http://dl.acm.org/citation.cfm?id=
          <volume>1939281</volume>
          .
          <fpage>1939332</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>R.</given-names>
            <surname>Baldoni</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Coppa</surname>
          </string-name>
          ,
          <string-name>
            <surname>D. C. D'Elia</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <string-name>
            <surname>Demetrescu</surname>
            ,
            <given-names>I. Finocchi,</given-names>
          </string-name>
          <article-title>A survey of symbolic execution techniques</article-title>
          ,
          <source>ACM Comput. Surv</source>
          .
          <volume>51</volume>
          (
          <year>2018</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <surname>Clang</surname>
            <given-names>SA</given-names>
          </string-name>
          , Clang Static Analyzer,
          <year>2019</year>
          . https://clang-analyzer.llvm.org/.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>Checker</given-names>
            <surname>Developer</surname>
          </string-name>
          <string-name>
            <surname>Manual</surname>
          </string-name>
          ,
          <source>Clang Static Analyzer: Checker Developer Manual</source>
          ,
          <year>2019</year>
          . https://clang-analyzer.llvm.org/checker_dev_manual.html (last accessed:
          <fpage>28</fpage>
          -
          <lpage>02</lpage>
          -
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>A.</given-names>
            <surname>Dergachev</surname>
          </string-name>
          , Clang Static Analyzer:
          <string-name>
            <given-names>A Checker</given-names>
            <surname>Developer's Guide</surname>
          </string-name>
          ,
          <year>2016</year>
          . https://github. com/haoNoQ/clang-analyzer-guide (last accessed:
          <fpage>28</fpage>
          -
          <lpage>02</lpage>
          -
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>A.</given-names>
            <surname>Zaks</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Rose</surname>
          </string-name>
          ,
          <article-title>Building a checker in 24 hours</article-title>
          ,
          <year>2012</year>
          . https://www.youtube.com/watch? v=
          <fpage>kdxlsP5QVPw</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>C.</given-names>
            <surname>Lattner</surname>
          </string-name>
          ,
          <article-title>Llvm and clang: Next generation compiler technology</article-title>
          ,
          <source>2008. Lecture at BSD Conference</source>
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <surname>Matthew</surname>
            <given-names>Albrecht</given-names>
          </string-name>
          , Acid game engine,
          <year>2023</year>
          . URL: https://github.com/EQMG/Acid.
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>F.</given-names>
            <surname>Developers</surname>
          </string-name>
          , Ffmpeg,
          <year>2023</year>
          . https://github.com/FFmpeg/FFmpeg.
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>C.</given-names>
            <surname>Lattner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Adve</surname>
          </string-name>
          ,
          <article-title>Llvm: A compilation framework for lifelong program analysis &amp; transformation (</article-title>
          <year>2004</year>
          )
          <fpage>75</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>OpenSSL</given-names>
            <surname>Software Foundation</surname>
          </string-name>
          , Openssl,
          <year>2022</year>
          . URL: https://openssl.org/.
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18] postgres Developers, postgres,
          <year>1986</year>
          . https://github.com/postgres/postgres.
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <article-title>QTBase developers</article-title>
          , Qtbase,
          <year>2023</year>
          . URL: https://github.com/qt/qtbase.
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          [20]
          <string-name>
            <given-names>A.</given-names>
            <surname>Robbins</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Hannah</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Lamb</surname>
          </string-name>
          ,
          <article-title>Learning the vi</article-title>
          and vim editors,
          <article-title>"</article-title>
          <string-name>
            <surname>O'Reilly Media</surname>
          </string-name>
          ,
          <source>Inc."</source>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          [21]
          <string-name>
            <given-names>Apache</given-names>
            <surname>Software</surname>
          </string-name>
          <string-name>
            <surname>Foundation</surname>
          </string-name>
          , Apache xerces,
          <year>2022</year>
          . URL: https://xerces.apache.org/.
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          [22]
          <string-name>
            <given-names>T.</given-names>
            <surname>Brunner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Szécsi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Porkoláb</surname>
          </string-name>
          ,
          <article-title>Bug path reduction strategies for symbolic execution</article-title>
          ,
          <source>in: THE 11TH CONFERENCE OF PHD STUDENTS IN COMPUTER SCIENCE</source>
          ,
          <year>2018</year>
          , p.
          <fpage>159</fpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>