[neon/qt/qtbase/Neon/testing] debian: Backport upstream patch to fix memory leak in QNetworkAccessManager.

Dmitry Shachnev null at kde.org
Tue May 18 11:01:29 BST 2021


Git commit 879fcb9df6ca688d0751a0987cbaea6ac02a4ce2 by Dmitry Shachnev.
Committed on 26/01/2021 at 12:34.
Pushed by sitter into branch 'Neon/testing'.

Backport upstream patch to fix memory leak in QNetworkAccessManager.

M  +3    -0    debian/changelog
A  +25   -0    debian/patches/qnam_connect_memory_leak.diff
M  +1    -0    debian/patches/series

https://invent.kde.org/neon/qt/qtbase/commit/879fcb9df6ca688d0751a0987cbaea6ac02a4ce2

diff --git a/debian/changelog b/debian/changelog
index 3ae9211..0815732 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,8 @@
 qtbase-opensource-src (5.15.2+dfsg-3) UNRELEASED; urgency=medium
 
+  [ Dmitry Shachnev ]
+  * Backport upstream patch to fix memory leak in QNetworkAccessManager
+    from QMetaObjectPrivate::connect.
 
  -- Debian Qt/KDE Maintainers <debian-qt-kde at lists.debian.org>  Tue, 26 Jan 2021 15:30:33 +0300
 
diff --git a/debian/patches/qnam_connect_memory_leak.diff b/debian/patches/qnam_connect_memory_leak.diff
new file mode 100644
index 0000000..f16b2bc
--- /dev/null
+++ b/debian/patches/qnam_connect_memory_leak.diff
@@ -0,0 +1,25 @@
+Description: QNAM: work around QObject finicky orphan cleanup details
+Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=0807f16eb407eaf8
+Last-Update: 2021-01-26
+
+--- a/src/network/access/qnetworkreplyhttpimpl.cpp
++++ b/src/network/access/qnetworkreplyhttpimpl.cpp
+@@ -808,7 +808,17 @@ void QNetworkReplyHttpImplPrivate::postR
+ 
+     // For the synchronous HTTP, this is the normal way the delegate gets deleted
+     // For the asynchronous HTTP this is a safety measure, the delegate deletes itself when HTTP is finished
+-    QObject::connect(thread, SIGNAL(finished()), delegate, SLOT(deleteLater()));
++    QMetaObject::Connection threadFinishedConnection =
++            QObject::connect(thread, SIGNAL(finished()), delegate, SLOT(deleteLater()));
++
++    // QTBUG-88063: When 'delegate' is deleted the connection will be added to 'thread''s orphaned
++    // connections list. This orphaned list will be cleaned up next time 'thread' emits a signal,
++    // unfortunately that's the finished signal. It leads to a soft-leak so we do this to disconnect
++    // it on deletion so that it cleans up the orphan immediately.
++    QObject::connect(delegate, &QObject::destroyed, delegate, [threadFinishedConnection]() {
++        if (bool(threadFinishedConnection))
++            QObject::disconnect(threadFinishedConnection);
++    });
+ 
+     // Set the properties it needs
+     delegate->httpRequest = httpRequest;
diff --git a/debian/patches/series b/debian/patches/series
index fa92882..4b4f79a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,5 +1,6 @@
 # Backported from upstream.
 xcb_screens_uaf.patch
+qnam_connect_memory_leak.diff
 
 # Debian specific.
 gnukfreebsd.diff



More information about the Neon-commits mailing list