Skip to content

Use after free warnings #4189

@aleks-f

Description

@aleks-f

Not sure at this point if false positives, just putting them here not to forget.

** Compiling src/AutoPtrTest.cpp (release, shared)
In member function ‘void {anonymous}::TestObj::release()’,
    inlined from ‘Poco::AutoPtr<C>::~AutoPtr() [with C = {anonymous}::TestObj]’ at /home/alex/tmp/poco/Foundation/include/Poco/AutoPtr.h:96:26,
    inlined from ‘void AutoPtrTest::testOps()’ at src/AutoPtrTest.cpp:185:1:
src/AutoPtrTest.cpp:48:31: warning: pointer ‘pTO1’ used after ‘void operator delete(void*, std::size_t)’ [-Wuse-after-free]
   48 |                         if (--_rc == 0)
      |                               ^~~
In member function ‘void {anonymous}::TestObj::release()’,
    inlined from ‘void {anonymous}::TestObj::release()’ at src/AutoPtrTest.cpp:46:8,
    inlined from ‘Poco::AutoPtr<C>::~AutoPtr() [with C = {anonymous}::TestObj]’ at /home/alex/tmp/poco/Foundation/include/Poco/AutoPtr.h:96:26,
    inlined from ‘void AutoPtrTest::testOps()’ at src/AutoPtrTest.cpp:185:1:
src/AutoPtrTest.cpp:49:40: note: call to ‘void operator delete(void*, std::size_t)’ here
   49 |                                 delete this;
      |                                        ^~~~
In member function ‘void {anonymous}::TestObj::release()’,
    inlined from ‘Poco::AutoPtr<C>::~AutoPtr() [with C = {anonymous}::TestObj]’ at /home/alex/tmp/poco/Foundation/include/Poco/AutoPtr.h:96:26,
    inlined from ‘void AutoPtrTest::testOps()’ at src/AutoPtrTest.cpp:185:1:
src/AutoPtrTest.cpp:48:31: warning: pointer ‘pTO1’ used after ‘void operator delete(void*, std::size_t)’ [-Wuse-after-free]
   48 |                         if (--_rc == 0)
      |                               ^~~
In member function ‘void {anonymous}::TestObj::release()’,
    inlined from ‘void {anonymous}::TestObj::release()’ at src/AutoPtrTest.cpp:46:8,
    inlined from ‘Poco::AutoPtr<C>::~AutoPtr() [with C = {anonymous}::TestObj]’ at /home/alex/tmp/poco/Foundation/include/Poco/AutoPtr.h:96:26,
    inlined from ‘void AutoPtrTest::testOps()’ at src/AutoPtrTest.cpp:185:1:
src/AutoPtrTest.cpp:49:40: note: call to ‘void operator delete(void*, std::size_t)’ here
   49 |                                 delete this;
      |                                        ^~~~
In member function ‘void {anonymous}::TestObj::release()’,
    inlined from ‘Poco::AutoPtr<C>::~AutoPtr() [with C = {anonymous}::TestObj]’ at /home/alex/tmp/poco/Foundation/include/Poco/AutoPtr.h:96:26,
    inlined from ‘void AutoPtrTest::testOps()’ at src/AutoPtrTest.cpp:185:1:
src/AutoPtrTest.cpp:48:35: warning: pointer ‘pTO1’ used after ‘void operator delete(void*, std::size_t)’ [-Wuse-after-free]
   48 |                         if (--_rc == 0)
      |                             ~~~~~~^~~~
In member function ‘void {anonymous}::TestObj::release()’,
    inlined from ‘void {anonymous}::TestObj::release()’ at src/AutoPtrTest.cpp:46:8,
    inlined from ‘Poco::AutoPtr<C>::~AutoPtr() [with C = {anonymous}::TestObj]’ at /home/alex/tmp/poco/Foundation/include/Poco/AutoPtr.h:96:26,
    inlined from ‘void AutoPtrTest::testOps()’ at src/AutoPtrTest.cpp:185:1:
src/AutoPtrTest.cpp:49:40: note: call to ‘void operator delete(void*, std::size_t)’ here
   49 |                                 delete this;
      |                                        ^~~~
** Compiling src/ArrayTest.cpp (release, shared)
** Compiling src/DirectoryWatcherTest.cpp (release, shared)
In file included from /home/alex/tmp/poco/Foundation/include/Poco/ObjectPool.h:25,
                 from src/ObjectPoolTest.cpp:14:
In constructor ‘Poco::SharedPtr<C, RC, RP>::SharedPtr(Poco::SharedPtr<C, RC, RP>&&) [with C = std::__cxx11::basic_string<char>; RC = Poco::ReferenceCounter; RP = Poco::ReleasePolicy<std::__cxx11::basic_string<char> >]’,
    inlined from ‘P Poco::ObjectPool<C, P, F>::activateObject(P) [with C = std::__cxx11::basic_string<char>; P = Poco::SharedPtr<std::__cxx11::basic_string<char> >; F = Poco::PoolableObjectFactory<std::__cxx11::basic_string<char>, Poco::SharedPtr<std::__cxx11::basic_string<char> > >]’ at /home/alex/tmp/poco/Foundation/include/Poco/ObjectPool.h:314:10,
    inlined from ‘P Poco::ObjectPool<C, P, F>::borrowObject(long int) [with C = std::__cxx11::basic_string<char>; P = Poco::SharedPtr<std::__cxx11::basic_string<char> >; F = Poco::PoolableObjectFactory<std::__cxx11::basic_string<char>, Poco::SharedPtr<std::__cxx11::basic_string<char> > >]’ at /home/alex/tmp/poco/Foundation/include/Poco/ObjectPool.h:241:33:
/home/alex/tmp/poco/Foundation/include/Poco/SharedPtr.h:152:17: warning: pointer used after ‘void operator delete(void*, std::size_t)’ [-Wuse-after-free]
  152 |                 _pCounter(ptr._pCounter),
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~
In member function ‘void Poco::SharedPtr<C, RC, RP>::release() [with C = std::__cxx11::basic_string<char>; RC = Poco::ReferenceCounter; RP = Poco::ReleasePolicy<std::__cxx11::basic_string<char> >]’,
    inlined from ‘void Poco::SharedPtr<C, RC, RP>::release() [with C = std::__cxx11::basic_string<char>; RC = Poco::ReferenceCounter; RP = Poco::ReleasePolicy<std::__cxx11::basic_string<char> >]’ at /home/alex/tmp/poco/Foundation/include/Poco/SharedPtr.h:439:7,
    inlined from ‘Poco::SharedPtr<C, RC, RP>::~SharedPtr() [with C = std::__cxx11::basic_string<char>; RC = Poco::ReferenceCounter; RP = Poco::ReleasePolicy<std::__cxx11::basic_string<char> >]’ at /home/alex/tmp/poco/Foundation/include/Poco/SharedPtr.h:161:10,
    inlined from ‘P Poco::ObjectPool<C, P, F>::activateObject(P) [with C = std::__cxx11::basic_string<char>; P = Poco::SharedPtr<std::__cxx11::basic_string<char> >; F = Poco::PoolableObjectFactory<std::__cxx11::basic_string<char>, Poco::SharedPtr<std::__cxx11::basic_string<char> > >]’ at /home/alex/tmp/poco/Foundation/include/Poco/ObjectPool.h:307:27,
    inlined from ‘P Poco::ObjectPool<C, P, F>::borrowObject(long int) [with C = std::__cxx11::basic_string<char>; P = Poco::SharedPtr<std::__cxx11::basic_string<char> >; F = Poco::PoolableObjectFactory<std::__cxx11::basic_string<char>, Poco::SharedPtr<std::__cxx11::basic_string<char> > >]’ at /home/alex/tmp/poco/Foundation/include/Poco/ObjectPool.h:241:33:
/home/alex/tmp/poco/Foundation/include/Poco/SharedPtr.h:446:25: note: call to ‘void operator delete(void*, std::size_t)’ here
  446 |                         delete _pCounter;
      |                         ^~~~~~~~~~~~~~~~
** Compiling src/DirectoryIteratorsTest.cpp (release, shared)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions