Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-116731

QtFuture::whenAll() leaks when one of the futures is already finished

    XMLWordPrintable

Details

    • ba2ebc24a (dev), a2792bac1 (6.6), 34eaba13b (6.6.0)

    Description

      The following leaks:

      auto f = QtFuture::makeReadyFuture(42);
      QtFuture::whenAll(f);  // leaks
      

      Only happens when the future is already finished by the team whenAll() is invoked. Test case for reproduction is attached.

      ASAN output:

      ❯ ./qtbug-116731
      Done
      
      =================================================================
      ==26147==ERROR: LeakSanitizer: detected memory leaks
      
      Indirect leak of 768 byte(s) in 8 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x7f2d9dd7dd08 in QWaitCondition::QWaitCondition() (/opt/qt6/lib/libQt6Core.so.6+0x2f9d08)
      
      Indirect leak of 416 byte(s) in 2 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x7f2d9dd818cf in QFutureInterfaceBase::QFutureInterfaceBase(QFutureInterfaceBase::State) (/opt/qt6/lib/libQt6Core.so.6+0x2fd8cf)
          #2 0x7f2d9d4e5082 in __libc_start_main ../csu/libc-start.c:308
      
      Indirect leak of 208 byte(s) in 1 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x7f2d9dd818cf in QFutureInterfaceBase::QFutureInterfaceBase(QFutureInterfaceBase::State) (/opt/qt6/lib/libQt6Core.so.6+0x2fd8cf)
          #2 0x55be712fcf8a in QFuture<QList<std::variant<QFuture<int> > > > QtPrivate::whenAllImpl<QList<std::variant<QFuture<int> > >, QFuture<int>&>(QFuture<int>&) (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x31f8a)
          #3 0x55be712d2143 in main (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x7143)
          #4 0x7f2d9d4e5082 in __libc_start_main ../csu/libc-start.c:308
      
      Indirect leak of 208 byte(s) in 1 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x7f2d9dd818cf in QFutureInterfaceBase::QFutureInterfaceBase(QFutureInterfaceBase::State) (/opt/qt6/lib/libQt6Core.so.6+0x2fd8cf)
          #2 0x55be712d2143 in main (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x7143)
          #3 0x7f2d9d4e5082 in __libc_start_main ../csu/libc-start.c:308
      
      Indirect leak of 112 byte(s) in 2 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x7f2d9dd84602 in QtPrivate::ResultStoreBase::insertResultItemIfValid(int, QtPrivate::ResultItem&) (/opt/qt6/lib/libQt6Core.so.6+0x300602)
      
      Indirect leak of 112 byte(s) in 2 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x7f2d9dd84e89 in QtPrivate::ResultStoreBase::syncPendingResults() (/opt/qt6/lib/libQt6Core.so.6+0x300e89)
      
      Indirect leak of 112 byte(s) in 2 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x7f2d9dd85487 in std::pair<std::_Rb_tree_iterator<std::pair<int const, QtPrivate::ResultItem> >, bool> std::_Rb_tree<int, std::pair<int const, QtPrivate::ResultItem>, std::_Select1st<std::pair<int const, QtPrivate::ResultItem> >, std::less<int>, std::allocator<std::pair<int const, QtPrivate::ResultItem> > >::_M_insert_unique<std::pair<int const, QtPrivate::ResultItem> >(std::pair<int const, QtPrivate::ResultItem>&&) (/opt/qt6/lib/libQt6Core.so.6+0x301487)
      
      Indirect leak of 66 byte(s) in 1 object(s) allocated from:
          #0 0x7f2d9ea95808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
          #1 0x7f2d9dd048d4 in QArrayData::allocate(QArrayData**, long long, long long, long long, QArrayData::AllocationOption) (/opt/qt6/lib/libQt6Core.so.6+0x2808d4)
      
      Indirect leak of 64 byte(s) in 1 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x55be712f2216 in void QtPrivate::Continuation<QtPrivate::addCompletionHandlersImpl<0ll, QtPrivate::WhenAllContext<QList<std::variant<QFuture<int> > > >, QFuture<int> >(std::shared_ptr<QtPrivate::WhenAllContext<QList<std::variant<QFuture<int> > > > > const&, std::tuple<QFuture<int> > const&)::{lambda(QFuture<int> const&)#1}, void, int>::create<{lambda(QFuture<int> const&)#1}>({lambda(QFuture<int> const&)#1}&&, QFuture<int>*, QFutureInterface<void>&, QtFuture::Launch) (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x27216)
          #2 0x55be712f3463 in void QtPrivate::addCompletionHandlersImpl<0ll, QtPrivate::WhenAllContext<QList<std::variant<QFuture<int> > > >, QFuture<int> >(std::shared_ptr<QtPrivate::WhenAllContext<QList<std::variant<QFuture<int> > > > > const&, std::tuple<QFuture<int> > const&) (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x28463)
          #3 0x55be712fcf8a in QFuture<QList<std::variant<QFuture<int> > > > QtPrivate::whenAllImpl<QList<std::variant<QFuture<int> > >, QFuture<int>&>(QFuture<int>&) (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x31f8a)
          #4 0x55be712d2143 in main (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x7143)
          #5 0x7f2d9d4e5082 in __libc_start_main ../csu/libc-start.c:308
      
      Indirect leak of 64 byte(s) in 1 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x55be712fcbea in QFuture<QList<std::variant<QFuture<int> > > > QtPrivate::whenAllImpl<QList<std::variant<QFuture<int> > >, QFuture<int>&>(QFuture<int>&) (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x31bea)
          #2 0x55be712d2143 in main (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x7143)
          #3 0x7f2d9d4e5082 in __libc_start_main ../csu/libc-start.c:308
      
      Indirect leak of 56 byte(s) in 1 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x55be712d24dd in main (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x74dd)
          #2 0x7f2d9d4e5082 in __libc_start_main ../csu/libc-start.c:308
      
      Indirect leak of 24 byte(s) in 1 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x55be712fedc8 in QtPrivate::Continuation<QtPrivate::addCompletionHandlersImpl<0ll, QtPrivate::WhenAllContext<QList<std::variant<QFuture<int> > > >, QFuture<int> >(std::shared_ptr<QtPrivate::WhenAllContext<QList<std::variant<QFuture<int> > > > > const&, std::tuple<QFuture<int> > const&)::{lambda(QFuture<int> const&)#1}, void, int>::runFunction() (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x33dc8)
          #2 0x55be712f8323 in QtPrivate::Continuation<QtPrivate::addCompletionHandlersImpl<0ll, QtPrivate::WhenAllContext<QList<std::variant<QFuture<int> > > >, QFuture<int> >(std::shared_ptr<QtPrivate::WhenAllContext<QList<std::variant<QFuture<int> > > > > const&, std::tuple<QFuture<int> > const&)::{lambda(QFuture<int> const&)#1}, void, int>::execute() (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x2d323)
          #3 0x55be712f89d8 in std::_Function_handler<void (QFutureInterfaceBase const&), QtPrivate::ContinuationWrapper<QtPrivate::Continuation<QtPrivate::addCompletionHandlersImpl<0ll, QtPrivate::WhenAllContext<QList<std::variant<QFuture<int> > > >, QFuture<int> >(std::shared_ptr<QtPrivate::WhenAllContext<QList<std::variant<QFuture<int> > > > > const&, std::tuple<QFuture<int> > const&)::{lambda(QFuture<int> const&)#1}, void, int>::create<{lambda(QFuture<int> const&)#1}>({lambda(QFuture<int> const&)#1}&&, QFuture<int>*, QFutureInterface<void>&, QtFuture::Launch)::{lambda(QFutureInterfaceBase const&)#1}> >::_M_invoke(std::_Any_data const&, QFutureInterfaceBase const&) (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x2d9d8)
          #4 0x7f2d9dd811fe in QFutureInterfaceBase::setContinuation(std::function<void (QFutureInterfaceBase const&)>, QFutureInterfaceBasePrivate*) (/opt/qt6/lib/libQt6Core.so.6+0x2fd1fe)
      
      Indirect leak of 4 byte(s) in 1 object(s) allocated from:
          #0 0x7f2d9ea97587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
          #1 0x55be712de991 in QFutureInterface<int>::reportAndMoveResult(int&&, int) (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x13991)
          #2 0x55be712d2072 in main (/home/arehn/tmp/qtbug-116731/qtbug-116731+0x7072)
          #3 0x7f2d9d4e5082 in __libc_start_main ../csu/libc-start.c:308
      
      SUMMARY: AddressSanitizer: 2214 byte(s) leaked in 24 allocation(s).
      

      Attachments

        For Gerrit Dashboard: QTBUG-116731
        # Subject Branch Project Status CR V

        Activity

          People

            ivan.solovev Ivan Solovev
            msarehn Arno Rehn
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes