[cfe-dev] scan-build "No bugs found."

Anna Zaks via cfe-dev cfe-dev at lists.llvm.org
Sat Feb 11 08:51:05 PST 2017


> On Jan 26, 2017, at 2:23 PM, Jack Bates via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> Thanks for offering to help me get to the bottom of this.
> 
> Here's the output of scan-build-py [1]. I ran it as follows:
> 
> 
>  $ PATH="~/Desktop/llvm/tools/clang/tools/scan-build-py/bin:$PATH" scan-build ./configure
>  $ PATH="~/Desktop/llvm/tools/clang/tools/scan-build-py/bin:$PATH" scan-build -v -v make V=1 2>&1 > ~/Desktop/scan-build-$(date +%s)
> 
> 
> Some lines were printed on the console, the last of which was:
> 
> 
>  scan-build: WARNING: Removing directory '/tmp/scan-build-2017-01-24-14-28-09-932827-5xhMxQ' because it contains no report.
> 
> 
> I suspect scan-build-py is using the version of Clang installed on my system -- which is only version 3.8.1. How do I get it to use the version that I built?
> 

There is an option to pass to scan-build to specify the clang binary to use for analysis. The expectation is that all scan-build options would also be available in scan-build-py, which is a new tool Laszlo is building.
--use-analyzer Xcode
or
--use-analyzer [path to clang]	scan-build uses the 'clang' executable relative to itself for static analysis. One can override this behavior with this option by using the 'clang' packaged with Xcode (on OS X) or from the PATH.
There is more information on scan-build usage here https://clang-analyzer.llvm.org/scan-build.html <https://clang-analyzer.llvm.org/scan-build.html>.

> Here's the output of the commands you listed:
> 
>> 
> [1] http://nottheoilrig.com/scan-build-1485293289 <http://nottheoilrig.com/scan-build-1485293289>
> 
> On 21/01/17 07:14 PM, Laszlo Nagy via cfe-dev wrote:
>> Hi Jack,
>> 
>> your report about the scan-build problem is a good feedback. But not
>> sure how well that piece of code is maintained, or these kind of issues
>> (lost bug reports, redirection problem) will be addressed... I did
>> recommend scan-build-py as an alternative solution. That has not been
>> released yet. As a developer of that tool I would glad to hear feedback
>> about it.
>> 
>> To use scan-build-py currently you don't need to compile the project.
>> Just make sure that your `PATH` environment contains the
>> `tools/scan-build-py/bin` directory. (This easiness planed to be
>> changed. ;)) I'm saying it because in your second mail, you compile the
>> Clang/LLVM sources, but you didn't run `make install`.
>> 
>> Could also send somehow the output of the these commands?
>> 
>> $ env # looking for the CC and CXX variables
>> $ command -v cc
>> $ command -v c++
>> $ command -v clang
>> $ command -v clang++
>> $ cc -v
>> $ c++ -v
>> $ clang -v
>> $ clang++ -v
>> 
>> Regards,
>> Laszlo
>> 
>> 
>> On Fri, Jan 20, 2017 at 7:40 AM, Jack Bates <n02qn5 at nottheoilrig.com
>> <mailto:n02qn5 at nottheoilrig.com <mailto:n02qn5 at nottheoilrig.com>>> wrote:
>> 
>>    Thanks for trying to reproduce my problem! I tried again with
>>    scan-build from the Clang source repository. Now I'm getting one bug
>>    and one crash. So I'm confident that the analyzer is doing
>>    *something*, but I still wonder why I'm not seeing the 22 bugs that
>>    you are?
>> 
>>    Am I running the same version of scan-build? Is there something
>>    about my environment that could explain the discrepancy? I'm running
>>    Debian Linux. Are the versions of any other tools on my system
>>    significant to this?
>> 
>>    Here's what I did this time:
>> 
>>      $ svn co http://llvm.org/svn/llvm-project/llvm/trunk <http://llvm.org/svn/llvm-project/llvm/trunk>
>>    <http://llvm.org/svn/llvm-project/llvm/trunk <http://llvm.org/svn/llvm-project/llvm/trunk>> llvm
>>      $ cd llvm/tools
>>      $ svn co http://llvm.org/svn/llvm-project/cfe/trunk <http://llvm.org/svn/llvm-project/cfe/trunk>
>>    <http://llvm.org/svn/llvm-project/cfe/trunk <http://llvm.org/svn/llvm-project/cfe/trunk>> clang
>>      $ cd ../..
>>      $ mkdir build
>>      $ cd build
>>      $ cmake ../llvm
>>      $ make
>>      $ cd ..
>>      $ git clone https://github.com/apache/trafficserver.git <https://github.com/apache/trafficserver.git>
>>    <https://github.com/apache/trafficserver.git <https://github.com/apache/trafficserver.git>>
>>      $ cd trafficserver
>>      $ autoreconf -i
>>      $ ./configure
>>      $ ../build/bin/scan-build -v -v make V=1 2>&1 > ~/Desktop/scan-build
>> 
>>    Here's the output [1] -- again, many lines were printed on the
>>    console instead. Here's the crash [2].
>> 
>>    Thanks for the tip about scan-build-py, I haven't tried that yet.
>> 
>>    [1] http://nottheoilrig.com/scan-build-1484839698 <http://nottheoilrig.com/scan-build-1484839698>
>>    <http://nottheoilrig.com/scan-build-1484839698 <http://nottheoilrig.com/scan-build-1484839698>>
>>    [2] http://nottheoilrig.com/failures <http://nottheoilrig.com/failures> <http://nottheoilrig.com/failures <http://nottheoilrig.com/failures>>
>> 
>>    On 18/01/17 06:30 AM, Laszlo Nagy wrote:
>> 
>>        Hi Jack,
>> 
>>        was following your recipe to analyze the traffic server. Was
>>        using the
>>        scan-build-py and scan-build from Clang source repo. Both was
>>        leaving me
>>        a non empty report directory with 22 bug reports.
>> 
>> 
>>        And `scan-build` is designed to run through `configure` too. It
>>        does not
>>        have a huge cost to do, so should not be an issue. But this case I
>>        agree, the generated makefiles are respecting the `CC` and `CXX`
>>        variables, therefore the interposition works.
>> 
>>        About the redirection problem. I don't know the answer. But I know a
>>        workaround it. If you use the `intercept-build` and
>>        `analyze-build` from
>>        scan-build-py, you can separate the interception phase from the
>>        actual
>>        static analyzer runs. And when you run `analyze-build` that can be
>>        redirected without this problem.
>> 
>>        Regards,
>>        Laszlo
>> 
>>        On Wed, Jan 18, 2017 at 9:39 AM, Jack Bates via cfe-dev
>>        <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org> <mailto:cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>>
>>        <mailto:cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org> <mailto:cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>>>>
>>        wrote:
>> 
>>            I'm running scan-build on Apache Traffic Server and getting
>>        "No bugs
>>            found.", which isn't what I expect.
>> 
>>            I ran it as follows:
>> 
>>              $ git clone https://github.com/apache/trafficserver.git <https://github.com/apache/trafficserver.git>
>>        <https://github.com/apache/trafficserver.git <https://github.com/apache/trafficserver.git>>
>>            <https://github.com/apache/trafficserver.git <https://github.com/apache/trafficserver.git>
>>        <https://github.com/apache/trafficserver.git <https://github.com/apache/trafficserver.git>>>
>>              $ cd trafficserver
>>              $ autoreconf -i
>>              $ ./configure
>>              $ scan-build -v -v make V=1 2>&1 > ~/Desktop/scan-build
>> 
>>            Here's the output [1].
>> 
>>            I didn't run ./configure through scan-build, but I conclude
>>        from the
>>            Make output that the compiler is being correctly interposed
>>        upon, so
>>            I shouldn't need to? The output indicates that the compiler is
>>            c++-analyzer.
>> 
>>            The output contains lines like the following, so I conclude
>>        that the
>>            analyzer is working?
>> 
>>              ANALYZE (Syntax): ../../lib/ts/ink_mutex.h
>>        ~x_pthread_mutexattr_t
>> 
>>            And it contains lines like "1 warning generated.", so I conclude
>>            that there should be bugs?
>> 
>>            So my first question is, why are there "No bugs found."?
>> 
>>            Also, although I redirect both stdout and stderr, the lines I
>>            mentioned -- "ANALYZE ..." and "1 warning generated." -- are
>>            nonetheless printed on the console, not [1]. Why is that?
>> 
>>            Thanks!
>> 
>>            [1] http://nottheoilrig.com/scan-build <http://nottheoilrig.com/scan-build>
>>        <http://nottheoilrig.com/scan-build <http://nottheoilrig.com/scan-build>>
>>            <http://nottheoilrig.com/scan-build <http://nottheoilrig.com/scan-build>
>>        <http://nottheoilrig.com/scan-build <http://nottheoilrig.com/scan-build>>>
>>            _______________________________________________
>>            cfe-dev mailing list
>>            cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org> <mailto:cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>>
>>        <mailto:cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org> <mailto:cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>>>
>>            http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>>        <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>>
>>            <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>>        <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>>>
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170211/cfd6e4c5/attachment.html>


More information about the cfe-dev mailing list