1 |
commit: 04865eef221ea16b0ec3c2b92f0a549bc56a8dce |
2 |
Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jan 7 15:54:57 2021 +0000 |
4 |
Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 7 16:30:35 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=04865eef |
7 |
|
8 |
dev-qt/qtcore: Fix allocated memory of QByteArray |
9 |
|
10 |
...returned by QIODevice::readLine. |
11 |
|
12 |
See also: https://bugreports.qt.io/browse/QTBUG-87010 |
13 |
Package-Manager: Portage-3.0.12, Repoman-3.0.2 |
14 |
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org> |
15 |
|
16 |
...qtcore-5.15.2-fix-alloc-mem-of-QByteArray.patch | 54 +++++++++++ |
17 |
dev-qt/qtcore/qtcore-5.15.2-r2.ebuild | 106 +++++++++++++++++++++ |
18 |
2 files changed, 160 insertions(+) |
19 |
|
20 |
diff --git a/dev-qt/qtcore/files/qtcore-5.15.2-fix-alloc-mem-of-QByteArray.patch b/dev-qt/qtcore/files/qtcore-5.15.2-fix-alloc-mem-of-QByteArray.patch |
21 |
new file mode 100644 |
22 |
index 00000000000..892d89d2948 |
23 |
--- /dev/null |
24 |
+++ b/dev-qt/qtcore/files/qtcore-5.15.2-fix-alloc-mem-of-QByteArray.patch |
25 |
@@ -0,0 +1,54 @@ |
26 |
+From 6485b6d45ad165cf976138cf8ab683c42515e794 Mon Sep 17 00:00:00 2001 |
27 |
+From: Kai Koehne <kai.koehne@××.io> |
28 |
+Date: Tue, 13 Oct 2020 15:47:31 +0200 |
29 |
+Subject: [PATCH] Fix allocated memory of QByteArray returned by |
30 |
+ QIODevice::readLine |
31 |
+ |
32 |
+If the maxSize argument is 0 (the default), QIODevice::readLine will |
33 |
+allocate a QByteArray with the size of the next chunk of data, which |
34 |
+may be quite large. Before returning, it then resizes the byte array |
35 |
+to the actual size that was read. |
36 |
+ |
37 |
+But since change 6b884d2aa129, QByteArray::resize() does no |
38 |
+longer shrink the capacity. This means that the returned QByteArray |
39 |
+keeps it's maximum size as allocated memory. This can lead to |
40 |
+excessive memory consumption, especially if the returned QByteArray's |
41 |
+are stored for further processing in the client code. |
42 |
+ |
43 |
+Fix this by explicitly calling QByteArray::squeeze() before returning. |
44 |
+ |
45 |
+[ChangeLog][QtCore][QIODevice] Fixes a regression in Qt 5.15 causing |
46 |
+QByteArray's that are returned by QIODevice::readLine() to |
47 |
+consume large amounts of memory. |
48 |
+ |
49 |
+Fixes: QTBUG-87010 |
50 |
+Change-Id: I1f95fc4098849e900680fc945238bfeda881022c |
51 |
+Reviewed-by: Thiago Macieira <thiago.macieira@×××××.com> |
52 |
+(cherry picked from commit 263b29eedb223dec1ecaee193302070af87a1852, |
53 |
+limited squeeze() call if bytes are actually read to preserve retVal.isNull() |
54 |
+behavior in 5.15) |
55 |
+--- |
56 |
+ src/corelib/io/qiodevice.cpp | 6 ++++-- |
57 |
+ 1 file changed, 4 insertions(+), 2 deletions(-) |
58 |
+ |
59 |
+diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp |
60 |
+index cc1d1102522..0f11c2e805c 100644 |
61 |
+--- a/src/corelib/io/qiodevice.cpp |
62 |
++++ b/src/corelib/io/qiodevice.cpp |
63 |
+@@ -1480,10 +1480,12 @@ QByteArray QIODevice::readLine(qint64 maxSize) |
64 |
+ } else |
65 |
+ readBytes = readLine(result.data(), result.size()); |
66 |
+ |
67 |
+- if (readBytes <= 0) |
68 |
++ if (readBytes <= 0) { |
69 |
+ result.clear(); |
70 |
+- else |
71 |
++ } else { |
72 |
+ result.resize(readBytes); |
73 |
++ result.squeeze(); |
74 |
++ } |
75 |
+ |
76 |
+ return result; |
77 |
+ } |
78 |
+-- |
79 |
+2.16.3 |
80 |
|
81 |
diff --git a/dev-qt/qtcore/qtcore-5.15.2-r2.ebuild b/dev-qt/qtcore/qtcore-5.15.2-r2.ebuild |
82 |
new file mode 100644 |
83 |
index 00000000000..3fce1aceac5 |
84 |
--- /dev/null |
85 |
+++ b/dev-qt/qtcore/qtcore-5.15.2-r2.ebuild |
86 |
@@ -0,0 +1,106 @@ |
87 |
+# Copyright 1999-2021 Gentoo Authors |
88 |
+# Distributed under the terms of the GNU General Public License v2 |
89 |
+ |
90 |
+EAPI=7 |
91 |
+ |
92 |
+QT5_MODULE="qtbase" |
93 |
+inherit linux-info qt5-build |
94 |
+ |
95 |
+DESCRIPTION="Cross-platform application development framework" |
96 |
+SLOT=5/$(ver_cut 1-3) |
97 |
+ |
98 |
+if [[ ${QT5_BUILD_TYPE} == release ]]; then |
99 |
+ KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~sparc ~x86" |
100 |
+fi |
101 |
+ |
102 |
+IUSE="icu old-kernel systemd" |
103 |
+ |
104 |
+DEPEND=" |
105 |
+ dev-libs/double-conversion:= |
106 |
+ dev-libs/glib:2 |
107 |
+ dev-libs/libpcre2[pcre16,unicode] |
108 |
+ sys-libs/zlib:= |
109 |
+ icu? ( dev-libs/icu:= ) |
110 |
+ !icu? ( virtual/libiconv ) |
111 |
+ systemd? ( sys-apps/systemd:= ) |
112 |
+" |
113 |
+RDEPEND="${DEPEND} |
114 |
+ !<dev-qt/qtcore-4.8.7-r4:4 |
115 |
+ dev-qt/qtchooser |
116 |
+" |
117 |
+ |
118 |
+QT5_TARGET_SUBDIRS=( |
119 |
+ src/tools/bootstrap |
120 |
+ src/tools/moc |
121 |
+ src/tools/rcc |
122 |
+ src/corelib |
123 |
+ src/tools/qlalr |
124 |
+ doc |
125 |
+) |
126 |
+ |
127 |
+QT5_GENTOO_PRIVATE_CONFIG=( |
128 |
+ !:network |
129 |
+ !:sql |
130 |
+ !:testlib |
131 |
+ !:xml |
132 |
+) |
133 |
+ |
134 |
+PATCHES=( |
135 |
+ "${FILESDIR}"/${PN}-5.14.1-cmake-macro-backward-compat.patch # bug 703306 |
136 |
+ "${FILESDIR}"/${PN}-5.15.1-timezone-{1,2}.patch # bug 737914 |
137 |
+ "${FILESDIR}"/${P}-fix-UB-in-QDateTime.patch # QTBUG-88656 |
138 |
+ "${FILESDIR}"/${P}-fix-alloc-mem-of-QByteArray.patch # QTBUG-87010 |
139 |
+) |
140 |
+ |
141 |
+pkg_pretend() { |
142 |
+ use kernel_linux || return |
143 |
+ get_running_version |
144 |
+ if kernel_is -lt 4 11 && ! use old-kernel; then |
145 |
+ ewarn "The running kernel is older than 4.11. USE=old-kernel is needed for" |
146 |
+ ewarn "dev-qt/qtcore to function on this kernel properly. Bugs #669994, #672856" |
147 |
+ fi |
148 |
+} |
149 |
+ |
150 |
+src_prepare() { |
151 |
+ # don't add -O3 to CXXFLAGS, bug 549140 |
152 |
+ sed -i -e '/CONFIG\s*+=/s/optimize_full//' src/corelib/corelib.pro || die |
153 |
+ |
154 |
+ # fix missing qt_version_tag symbol w/ LTO, bug 674382 |
155 |
+ sed -i -e 's/^gcc:ltcg/gcc/' src/corelib/global/global.pri || die |
156 |
+ |
157 |
+ qt5-build_src_prepare |
158 |
+} |
159 |
+ |
160 |
+src_configure() { |
161 |
+ local myconf=( |
162 |
+ $(qt_use icu) |
163 |
+ $(qt_use !icu iconv) |
164 |
+ $(qt_use systemd journald) |
165 |
+ ) |
166 |
+ use old-kernel && myconf+=( |
167 |
+ -no-feature-renameat2 # needs Linux 3.16, bug 669994 |
168 |
+ -no-feature-getentropy # needs Linux 3.17, bug 669994 |
169 |
+ -no-feature-statx # needs Linux 4.11, bug 672856 |
170 |
+ ) |
171 |
+ qt5-build_src_configure |
172 |
+} |
173 |
+ |
174 |
+src_install() { |
175 |
+ qt5-build_src_install |
176 |
+ |
177 |
+ local flags=( |
178 |
+ DBUS FREETYPE IMAGEFORMAT_JPEG IMAGEFORMAT_PNG |
179 |
+ OPENGL OPENSSL SSL WIDGETS |
180 |
+ ) |
181 |
+ |
182 |
+ for flag in ${flags[@]}; do |
183 |
+ cat >> "${D}"/${QT5_HEADERDIR}/QtCore/qconfig.h <<- _EOF_ || die |
184 |
+ |
185 |
+ #if defined(QT_NO_${flag}) && defined(QT_${flag}) |
186 |
+ # undef QT_NO_${flag} |
187 |
+ #elif !defined(QT_NO_${flag}) && !defined(QT_${flag}) |
188 |
+ # define QT_NO_${flag} |
189 |
+ #endif |
190 |
+ _EOF_ |
191 |
+ done |
192 |
+} |