Gentoo Archives: gentoo-commits

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-p2p/ktorrent/, net-p2p/ktorrent/files/
Date: Sat, 08 Sep 2018 12:09:24
Message-Id: 1536408228.e1215ae690131a79d311de83a1b26259ed0d09eb.asturm@gentoo
1 commit: e1215ae690131a79d311de83a1b26259ed0d09eb
2 Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 8 11:26:34 2018 +0000
4 Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 8 12:03:48 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e1215ae6
7
8 net-p2p/ktorrent: 5.1.1 version bump
9
10 Package-Manager: Portage-2.3.49, Repoman-2.3.10
11
12 net-p2p/ktorrent/Manifest | 1 +
13 .../ktorrent-5.1.1-scanfolder-memcorruption.patch | 69 ++++++++++++++
14 net-p2p/ktorrent/ktorrent-5.1.1.ebuild | 105 +++++++++++++++++++++
15 3 files changed, 175 insertions(+)
16
17 diff --git a/net-p2p/ktorrent/Manifest b/net-p2p/ktorrent/Manifest
18 index b6dda2840ea..01fb39595d9 100644
19 --- a/net-p2p/ktorrent/Manifest
20 +++ b/net-p2p/ktorrent/Manifest
21 @@ -1 +1,2 @@
22 DIST ktorrent-5.1.0.tar.xz 2046916 BLAKE2B 865004b84d649774420e2bd0087c416c5de4df40dfe5800ec539049001d93f66925025780987060ad09e1ba2a20045bd6d92c9202c98c28ec68d87758a88af74 SHA512 7bfe3a04a2b0f62d68b41c946af34e9f6ead6aa4ff7818a9c0ce2e83629d311e9e9be5fb1689065ce2601c43bd576b27d8c6946b845d4cdf5fa6362d53e8dd25
23 +DIST ktorrent-5.1.1.tar.xz 2049392 BLAKE2B 09ad841e1b6d7f332b19e2a660130b1f2b998cd6839614800cde7c99c8ec7f119f2adbdc3d9e06c8525e2dde534d73dab521c7df1d01b2fd0eb6b11fbb868d8f SHA512 bbe744853018380e30efc6ef95916a9b6f0ebec812d70d7970e5e7183d860d147b0693dd0107b146a5987aa27f30cd335fad73c8967839d53eee1c5b63a53c06
24
25 diff --git a/net-p2p/ktorrent/files/ktorrent-5.1.1-scanfolder-memcorruption.patch b/net-p2p/ktorrent/files/ktorrent-5.1.1-scanfolder-memcorruption.patch
26 new file mode 100644
27 index 00000000000..4c41a6af11d
28 --- /dev/null
29 +++ b/net-p2p/ktorrent/files/ktorrent-5.1.1-scanfolder-memcorruption.patch
30 @@ -0,0 +1,69 @@
31 +From 2d73d5f25a1a364a2115fb1d3262377f7fdf99cd Mon Sep 17 00:00:00 2001
32 +From: Valeriy Malov <jazzvoid@×××××.com>
33 +Date: Wed, 5 Sep 2018 20:43:51 +0300
34 +Subject: Fix memory corruption in ScanFolder plugin
35 +
36 +Summary:
37 +Reasoning behind this patch is kinda dubious because I don't fully understand what happens, but it shouldn't make the matters worse either
38 +
39 +Seems like deletion of KDirWatch objects from scan_folder in ~ScanThread(), after said QThread has been stopped, causes memory corruption.
40 +
41 +Preemptively deleting scan_folder contents before we stop the thread resolves this.
42 +
43 +also mark booleans shared across main thread and KDirWatch callbacks as atomic
44 +
45 +Test Plan:
46 +Without this patch unloading ScanFolder plugin sometimes crashes ktorrent, including unloading on exit
47 +Doesn't happen anymore with this patch
48 +
49 +Reviewers: stikonas
50 +
51 +Reviewed By: stikonas
52 +
53 +Differential Revision: https://phabricator.kde.org/D15265
54 +---
55 + plugins/scanfolder/scanthread.cpp | 5 +++++
56 + plugins/scanfolder/scanthread.h | 5 +++--
57 + 2 files changed, 8 insertions(+), 2 deletions(-)
58 +
59 +diff --git a/plugins/scanfolder/scanthread.cpp b/plugins/scanfolder/scanthread.cpp
60 +index 0e62768..d7b13e0 100644
61 +--- a/plugins/scanfolder/scanthread.cpp
62 ++++ b/plugins/scanfolder/scanthread.cpp
63 +@@ -156,6 +156,11 @@ namespace kt
64 + void ScanThread::stop()
65 + {
66 + stop_requested = true;
67 ++
68 ++ // XXX seems like deleting KDirWatch object(s) created in scan_folders
69 ++ // in destructor of this QThread after it has been stopped
70 ++ // causes memory corruption, so we delete them early
71 ++ scan_folders.clear();
72 + exit();
73 + wait();
74 + }
75 +diff --git a/plugins/scanfolder/scanthread.h b/plugins/scanfolder/scanthread.h
76 +index d13ca08..fb214a4 100644
77 +--- a/plugins/scanfolder/scanthread.h
78 ++++ b/plugins/scanfolder/scanthread.h
79 +@@ -29,6 +29,7 @@
80 + #include <util/ptrmap.h>
81 + #include "scanfolder.h"
82 +
83 ++#include <atomic>
84 +
85 + class QDir;
86 +
87 +@@ -88,8 +89,8 @@ namespace kt
88 + private:
89 + QMutex mutex;
90 + QStringList folders;
91 +- bool stop_requested;
92 +- bool recursive;
93 ++ std::atomic<bool> stop_requested;
94 ++ std::atomic<bool> recursive;
95 + bt::PtrMap<QString, ScanFolder> scan_folders;
96 + };
97 +
98 +--
99 +cgit v0.11.2
100
101 diff --git a/net-p2p/ktorrent/ktorrent-5.1.1.ebuild b/net-p2p/ktorrent/ktorrent-5.1.1.ebuild
102 new file mode 100644
103 index 00000000000..6283ae3c7ca
104 --- /dev/null
105 +++ b/net-p2p/ktorrent/ktorrent-5.1.1.ebuild
106 @@ -0,0 +1,105 @@
107 +# Copyright 1999-2018 Gentoo Foundation
108 +# Distributed under the terms of the GNU General Public License v2
109 +
110 +EAPI=6
111 +
112 +FRAMEWORKS_MINIMAL="5.50.0" # for syndication
113 +KDE_HANDBOOK="forceoptional"
114 +KDE_TEST="optional"
115 +VIRTUALX_REQUIRED="test"
116 +inherit kde5
117 +
118 +DESCRIPTION="Powerful BitTorrent client based on KDE Frameworks"
119 +HOMEPAGE="https://www.kde.org/applications/internet/ktorrent/"
120 +[[ ${KDE_BUILD_TYPE} = release ]] && SRC_URI="mirror://kde/stable/${PN}/${PV/%.0}/${P}.tar.xz"
121 +
122 +LICENSE="GPL-2"
123 +KEYWORDS="~amd64 ~x86"
124 +IUSE="+bwscheduler +downloadorder +infowidget +ipfilter +kross +logviewer +magnetgenerator
125 ++mediaplayer rss +scanfolder +search +shutdown +stats +upnp +zeroconf"
126 +
127 +COMMON_DEPEND="
128 + $(add_frameworks_dep kcmutils)
129 + $(add_frameworks_dep kconfig)
130 + $(add_frameworks_dep kconfigwidgets)
131 + $(add_frameworks_dep kcoreaddons)
132 + $(add_frameworks_dep kcrash)
133 + $(add_frameworks_dep kdbusaddons)
134 + $(add_frameworks_dep ki18n)
135 + $(add_frameworks_dep kiconthemes)
136 + $(add_frameworks_dep kio)
137 + $(add_frameworks_dep knotifications)
138 + $(add_frameworks_dep knotifyconfig)
139 + $(add_frameworks_dep kparts)
140 + $(add_frameworks_dep kwidgetsaddons)
141 + $(add_frameworks_dep kwindowsystem)
142 + $(add_frameworks_dep kxmlgui)
143 + $(add_frameworks_dep solid)
144 + $(add_qt_dep qtdbus)
145 + $(add_qt_dep qtgui)
146 + $(add_qt_dep qtnetwork)
147 + $(add_qt_dep qtwidgets)
148 + $(add_qt_dep qtxml)
149 + =net-libs/libktorrent-2.1*:5
150 + infowidget? ( dev-libs/geoip )
151 + kross? (
152 + $(add_frameworks_dep karchive)
153 + $(add_frameworks_dep kitemviews)
154 + $(add_frameworks_dep kross)
155 + )
156 + mediaplayer? (
157 + media-libs/phonon[qt5(+)]
158 + >=media-libs/taglib-1.5
159 + )
160 + rss? (
161 + $(add_frameworks_dep kdewebkit)
162 + $(add_frameworks_dep syndication)
163 + )
164 + search? (
165 + $(add_frameworks_dep kdewebkit)
166 + $(add_qt_dep qtwebkit)
167 + )
168 + shutdown? ( $(add_plasma_dep plasma-workspace) )
169 + stats? ( $(add_frameworks_dep kplotting) )
170 + upnp? ( $(add_frameworks_dep kcompletion) )
171 + zeroconf? ( $(add_frameworks_dep kdnssd) )
172 +"
173 +DEPEND="${COMMON_DEPEND}
174 + dev-libs/boost
175 + sys-devel/gettext
176 +"
177 +RDEPEND="${COMMON_DEPEND}
178 + ipfilter? (
179 + app-arch/bzip2
180 + app-arch/unzip
181 + $(add_frameworks_dep ktextwidgets)
182 + $(add_kdeapps_dep kio-extras)
183 + )
184 + !net-p2p/ktorrent:4
185 +"
186 +
187 +PATCHES=( "${FILESDIR}/${P}-scanfolder-memcorruption.patch" )
188 +
189 +src_configure() {
190 + local mycmakeargs=(
191 + -DENABLE_BWSCHEDULER_PLUGIN=$(usex bwscheduler)
192 + -DENABLE_DOWNLOADORDER_PLUGIN=$(usex downloadorder)
193 + -DENABLE_INFOWIDGET_PLUGIN=$(usex infowidget)
194 + -DWITH_SYSTEM_GEOIP=$(usex infowidget)
195 + -DENABLE_IPFILTER_PLUGIN=$(usex ipfilter)
196 + -DENABLE_SCRIPTING_PLUGIN=$(usex kross)
197 + -DENABLE_LOGVIEWER_PLUGIN=$(usex logviewer)
198 + -DENABLE_MAGNETGENERATOR_PLUGIN=$(usex magnetgenerator)
199 + -DENABLE_MEDIAPLAYER_PLUGIN=$(usex mediaplayer)
200 + $(cmake-utils_use_find_package rss KF5Syndication)
201 + -DENABLE_SCANFOLDER_PLUGIN=$(usex scanfolder)
202 + -DENABLE_SEARCH_PLUGIN=$(usex search)
203 + -DENABLE_SHUTDOWN_PLUGIN=$(usex shutdown)
204 + -DENABLE_STATS_PLUGIN=$(usex stats)
205 + -DENABLE_UPNP_PLUGIN=$(usex upnp)
206 + -DENABLE_ZEROCONF_PLUGIN=$(usex zeroconf)
207 + )
208 +# add back when ported
209 +# -DENABLE_WEBINTERFACE_PLUGIN=$(usex webinterface)
210 + kde5_src_configure
211 +}