[llvm-bugs] [Bug 52544] New: scan-build reports false-positive with boost signals

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 18 03:48:05 PST 2021


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

            Bug ID: 52544
           Summary: scan-build reports false-positive with boost signals
           Product: clang
           Version: 13.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: florian at apolloner.eu
                CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org

Created attachment 25457
  --> https://bugs.llvm.org/attachment.cgi?id=25457&action=edit
HTML output of scan-build

Hi there,

I have scan-build reporting a false positive. I am not 100% sure though, since
this code is a bit over my head and my analysis might have been wrong.

What I did so far:
 * I ran valgrind --track-origins=yes --leak-check=full and
 * the address sanitizer (-O1 -g -fsanitize=address -fno-omit-frame-pointer)
over the code and they did not complain.

Looking through the report I think it might indeed be a bug in scan-build
(although it might not be easily fixable and might have to be reported to boost
signals2/smart_ptr instead).

I have attached the generated html output, the cpp in question is:

```
#include <boost/signals2.hpp>
#include <boost/bind/bind.hpp>
#include <iostream>

using namespace boost;
using namespace boost::signals2;
using namespace std;

signal<void ()> SigA;

struct ClassB
{
    void PrintFoo() { cout << "Foo" << endl; }
};

int main()
{
    ClassB b;
    SigA.connect(bind(&ClassB::PrintFoo, &b));
}
```
and scan-build reports:
```
scan-build: Using '/usr/bin/clang-13' for static analysis
In file included from test.cpp:1:
In file included from /usr/include/boost/signals2.hpp:15:
In file included from /usr/include/boost/signals2/deconstruct.hpp:28:
In file included from /usr/include/boost/shared_ptr.hpp:17:
In file included from /usr/include/boost/smart_ptr/shared_ptr.hpp:17:
/usr/include/boost/smart_ptr/detail/shared_count.hpp:586:22: warning: Use of
memory after it is freed [cplusplus.NewDelete]
        if(pi_ != 0) pi_->weak_release();
                     ^~~~~~~~~~~~~~~~~~~
1 warning generated.
scan-build: Analysis run complete.
scan-build: 1 bug found.
scan-build: Run 'scan-view /tmp/scan-build-2021-11-18-124707-36387-1' to
examine bug reports.
```

Please let me know what you need and whether I should report this to boost
instead.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211118/fd0e1133/attachment-0001.html>


More information about the llvm-bugs mailing list