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

QFactoryLoader memory leak on follow-up setExtraPath()

    XMLWordPrintable

Details

    • 3
    • e60aed5ed (dev), fae7afba3 (6.5), 30ffd6639 (6.6)
    • Foundation Sprint 86, Foundation Sprint 87

    Description

      The tst_QFactoryLoader::extraSearchPath() test appears to leaks QLibraryPrivate* objects stored in keyMap.

      Log attached, which, at the end, shows that this is the only function with a problem, all other test functions are clean (by themselves, if run together with extraSearchPath(), the locations reported may seem to originate from other tests).

      The debug output is from the patch pasted below, which indicates that it's the keyMap.clear() which is the problem, not (at least in this case) the overwriting of previous.

      I don't know how the ref-counting is supposed to work vis-a-via our never-unload-plugins policy, though I guess it'll be obvious what's happening for you, thiago.

      diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
      index e3649622bd..b254738a0f 100644
      --- a/src/corelib/plugin/qfactoryloader.cpp
      +++ b/src/corelib/plugin/qfactoryloader.cpp
      @@ -222,6 +222,7 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path)
                       prev_qt_version = int(previous->metaData.value(QtPluginMetaDataKeys::QtVersion).toInteger());
                   int qt_version = int(library->metaData.value(QtPluginMetaDataKeys::QtVersion).toInteger());
                   if (!previous || (prev_qt_version > QtVersionNoPatch && qt_version <= QtVersionNoPatch)) {
      +                qDebug("%s: %p leaked?", Q_FUNC_INFO, previous);
                       keyMap[key] = library.get();    // we WILL .release()
                       ++keyUsageCount;
                   }
      @@ -329,6 +330,9 @@ void QFactoryLoader::setExtraSearchPath(const QString &path)
               // must re-scan everything
               d->loadedPaths.clear();
               d->libraryList.clear();
      +        qDebug("%s: leaking %lld objects?", Q_FUNC_INFO, qlonglong(d->keyMap.size()));
      +        for (auto p : std::as_const(d->keyMap))
      +            qDebug("%s: candidate: %p", Q_FUNC_INFO, p);
               d->keyMap.clear();
               update();
           }
      

      Attachments

        Issue Links

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

          Activity

            People

              mmutz Marc Mutz
              mmutz Marc Mutz
              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