1 |
commit: a38330bcb61155bcb7897f71ce07ba34272d4b9f |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu May 12 17:45:47 2022 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu May 12 17:50:08 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a38330bc |
7 |
|
8 |
app-i18n/ibus: Fix memory leak |
9 |
|
10 |
Closes: https://bugs.gentoo.org/843725 |
11 |
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> |
12 |
|
13 |
.../ibus-1.5.26-src-Fix-refcounting-issues.patch | 273 +++++++++++++++++++++ |
14 |
.../{ibus-1.5.26.ebuild => ibus-1.5.26-r1.ebuild} | 4 + |
15 |
2 files changed, 277 insertions(+) |
16 |
|
17 |
diff --git a/app-i18n/ibus/files/ibus-1.5.26-src-Fix-refcounting-issues.patch b/app-i18n/ibus/files/ibus-1.5.26-src-Fix-refcounting-issues.patch |
18 |
new file mode 100644 |
19 |
index 000000000000..5bd610024a1b |
20 |
--- /dev/null |
21 |
+++ b/app-i18n/ibus/files/ibus-1.5.26-src-Fix-refcounting-issues.patch |
22 |
@@ -0,0 +1,273 @@ |
23 |
+https://github.com/ibus/ibus/issues/2387 |
24 |
+https://bugs.gentoo.org/843725 |
25 |
+ |
26 |
+From 17648f0522910480b6c5dd4f5356ca1f6c160bf5 Mon Sep 17 00:00:00 2001 |
27 |
+From: Carlos Garnacho <carlosg@×××××.org> |
28 |
+Date: Tue, 29 Mar 2022 22:48:19 +0200 |
29 |
+Subject: [PATCH] src: Fix refcounting issues |
30 |
+ |
31 |
+Commit 5a455b1ead attempted to fix both GLib warnings around |
32 |
+floating references and other presumed refcounting issues. However |
33 |
+it missed 2 kinds of bugs: |
34 |
+ |
35 |
+- The places that take an IBusText created from a static string |
36 |
+ were made to avoid freeing it afterwards, but the staticness refers |
37 |
+ to the string content, not the object itself. |
38 |
+- The places that are documented to emit signals on floating object |
39 |
+ references used to do the following after signal emission: |
40 |
+ |
41 |
+ if (g_object_is_floating (object)) |
42 |
+ g_object_unref (object) |
43 |
+ |
44 |
+ And did possibly trigger GLib warnings were changed to: |
45 |
+ |
46 |
+ if (g_object_is_floating (object)) |
47 |
+ g_object_sink_ref (object); |
48 |
+ g_object_unref (object); |
49 |
+ |
50 |
+ Which fixes the GLib warning for floating references, but do |
51 |
+ unintendedly steal one reference away for non floating references. |
52 |
+ |
53 |
+This commit is essentially a revert of commit 5a455b1ead, but |
54 |
+addressing both things differently: |
55 |
+ |
56 |
+- All label/tooltip/symbol IBusText properties in IBusProperty do |
57 |
+ now always sink the reference of the stored object. |
58 |
+ |
59 |
+- All places documented as maybe using objects with a floating reference |
60 |
+ on signals changed to doing: |
61 |
+ |
62 |
+ if (g_object_is_floating (object)) { |
63 |
+ g_object_ref_sink (object); |
64 |
+ g_object_unref (object); |
65 |
+ } |
66 |
+ |
67 |
+ So the floating reference is owned and unreferenced without warnings, |
68 |
+ but already owned references are left unchanged. |
69 |
+ |
70 |
+This addresses the possible GLib warnings, fixes the possible double |
71 |
+unrefs happening on IBusText used in signals, and fixes the missing |
72 |
+unrefs on IBusText objects created from static strings. |
73 |
+ |
74 |
+BUG=https://github.com/ibus/ibus/issues/2393 |
75 |
+BUG=https://github.com/ibus/ibus/issues/2387 |
76 |
+--- |
77 |
+ src/ibusinputcontext.c | 35 +++++++++++++++++++++-------------- |
78 |
+ src/ibusproperty.c | 32 +++++++++++++++++--------------- |
79 |
+ 2 files changed, 38 insertions(+), 29 deletions(-) |
80 |
+ |
81 |
+diff --git a/src/ibusinputcontext.c b/src/ibusinputcontext.c |
82 |
+index 4b27551b..7981de38 100644 |
83 |
+--- a/src/ibusinputcontext.c |
84 |
++++ b/src/ibusinputcontext.c |
85 |
+@@ -549,9 +549,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, |
86 |
+ g_variant_unref (variant); |
87 |
+ g_signal_emit (context, context_signals[COMMIT_TEXT], 0, text); |
88 |
+ |
89 |
+- if (g_object_is_floating (text)) |
90 |
++ if (g_object_is_floating (text)) { |
91 |
+ g_object_ref_sink (text); |
92 |
+- g_object_unref (text); |
93 |
++ g_object_unref (text); |
94 |
++ } |
95 |
+ return; |
96 |
+ } |
97 |
+ if (g_strcmp0 (signal_name, "UpdatePreeditText") == 0) { |
98 |
+@@ -569,9 +570,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, |
99 |
+ cursor_pos, |
100 |
+ visible); |
101 |
+ |
102 |
+- if (g_object_is_floating (text)) |
103 |
++ if (g_object_is_floating (text)) { |
104 |
+ g_object_ref_sink (text); |
105 |
+- g_object_unref (text); |
106 |
++ g_object_unref (text); |
107 |
++ } |
108 |
+ return; |
109 |
+ } |
110 |
+ if (g_strcmp0 (signal_name, "UpdatePreeditTextWithMode") == 0) { |
111 |
+@@ -592,9 +594,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, |
112 |
+ visible, |
113 |
+ mode); |
114 |
+ |
115 |
+- if (g_object_is_floating (text)) |
116 |
++ if (g_object_is_floating (text)) { |
117 |
+ g_object_ref_sink (text); |
118 |
+- g_object_unref (text); |
119 |
++ g_object_unref (text); |
120 |
++ } |
121 |
+ return; |
122 |
+ } |
123 |
+ |
124 |
+@@ -621,9 +624,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, |
125 |
+ 0, |
126 |
+ text, |
127 |
+ visible); |
128 |
+- if (g_object_is_floating (text)) |
129 |
++ if (g_object_is_floating (text)) { |
130 |
+ g_object_ref_sink (text); |
131 |
+- g_object_unref (text); |
132 |
++ g_object_unref (text); |
133 |
++ } |
134 |
+ return; |
135 |
+ } |
136 |
+ |
137 |
+@@ -640,9 +644,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, |
138 |
+ 0, |
139 |
+ table, |
140 |
+ visible); |
141 |
+- if (g_object_is_floating (table)) |
142 |
++ if (g_object_is_floating (table)) { |
143 |
+ g_object_ref_sink (table); |
144 |
+- g_object_unref (table); |
145 |
++ g_object_unref (table); |
146 |
++ } |
147 |
+ return; |
148 |
+ |
149 |
+ } |
150 |
+@@ -659,9 +664,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, |
151 |
+ 0, |
152 |
+ prop_list); |
153 |
+ |
154 |
+- if (g_object_is_floating (prop_list)) |
155 |
++ if (g_object_is_floating (prop_list)) { |
156 |
+ g_object_ref_sink (prop_list); |
157 |
+- g_object_unref (prop_list); |
158 |
++ g_object_unref (prop_list); |
159 |
++ } |
160 |
+ return; |
161 |
+ } |
162 |
+ |
163 |
+@@ -673,9 +679,10 @@ ibus_input_context_g_signal (GDBusProxy *proxy, |
164 |
+ |
165 |
+ g_signal_emit (context, context_signals[UPDATE_PROPERTY], 0, prop); |
166 |
+ |
167 |
+- if (g_object_is_floating (prop)) |
168 |
++ if (g_object_is_floating (prop)) { |
169 |
+ g_object_ref_sink (prop); |
170 |
+- g_object_unref (prop); |
171 |
++ g_object_unref (prop); |
172 |
++ } |
173 |
+ return; |
174 |
+ } |
175 |
+ |
176 |
+diff --git a/src/ibusproperty.c b/src/ibusproperty.c |
177 |
+index 6d4ed088..cd8a0e2a 100644 |
178 |
+--- a/src/ibusproperty.c |
179 |
++++ b/src/ibusproperty.c |
180 |
+@@ -336,20 +336,17 @@ ibus_property_destroy (IBusProperty *prop) |
181 |
+ prop->priv->icon = NULL; |
182 |
+ |
183 |
+ if (prop->priv->label) { |
184 |
+- if (!ibus_text_get_is_static (prop->priv->label)) |
185 |
+- g_object_unref (prop->priv->label); |
186 |
++ g_object_unref (prop->priv->label); |
187 |
+ prop->priv->label = NULL; |
188 |
+ } |
189 |
+ |
190 |
+ if (prop->priv->symbol) { |
191 |
+- if (!ibus_text_get_is_static (prop->priv->symbol)) |
192 |
+- g_object_unref (prop->priv->symbol); |
193 |
++ g_object_unref (prop->priv->symbol); |
194 |
+ prop->priv->symbol = NULL; |
195 |
+ } |
196 |
+ |
197 |
+ if (prop->priv->tooltip) { |
198 |
+- if (!ibus_text_get_is_static (prop->priv->tooltip)) |
199 |
+- g_object_unref (prop->priv->tooltip); |
200 |
++ g_object_unref (prop->priv->tooltip); |
201 |
+ prop->priv->tooltip = NULL; |
202 |
+ } |
203 |
+ |
204 |
+@@ -404,7 +401,7 @@ ibus_property_deserialize (IBusProperty *prop, |
205 |
+ g_variant_get_child (variant, retval++, "u", &prop->priv->type); |
206 |
+ |
207 |
+ GVariant *subvar = g_variant_get_child_value (variant, retval++); |
208 |
+- if (prop->priv->label && !ibus_text_get_is_static (prop->priv->label)) { |
209 |
++ if (prop->priv->label) { |
210 |
+ g_object_unref (prop->priv->label); |
211 |
+ } |
212 |
+ prop->priv->label = IBUS_TEXT (ibus_serializable_deserialize (subvar)); |
213 |
+@@ -414,7 +411,7 @@ ibus_property_deserialize (IBusProperty *prop, |
214 |
+ ibus_g_variant_get_child_string (variant, retval++, &prop->priv->icon); |
215 |
+ |
216 |
+ subvar = g_variant_get_child_value (variant, retval++); |
217 |
+- if (prop->priv->tooltip && !ibus_text_get_is_static (prop->priv->tooltip)) { |
218 |
++ if (prop->priv->tooltip) { |
219 |
+ g_object_unref (prop->priv->tooltip); |
220 |
+ } |
221 |
+ prop->priv->tooltip = IBUS_TEXT (ibus_serializable_deserialize (subvar)); |
222 |
+@@ -435,7 +432,7 @@ ibus_property_deserialize (IBusProperty *prop, |
223 |
+ |
224 |
+ /* Keep the serialized order for the compatibility when add new members. */ |
225 |
+ subvar = g_variant_get_child_value (variant, retval++); |
226 |
+- if (prop->priv->symbol && !ibus_text_get_is_static (prop->priv->symbol)) { |
227 |
++ if (prop->priv->symbol) { |
228 |
+ g_object_unref (prop->priv->symbol); |
229 |
+ } |
230 |
+ prop->priv->symbol = IBUS_TEXT (ibus_serializable_deserialize (subvar)); |
231 |
+@@ -567,7 +564,7 @@ ibus_property_set_label (IBusProperty *prop, |
232 |
+ g_assert (IBUS_IS_PROPERTY (prop)); |
233 |
+ g_return_if_fail (label == NULL || IBUS_IS_TEXT (label)); |
234 |
+ |
235 |
+- if (prop->priv->label && !ibus_text_get_is_static (prop->priv->label)) { |
236 |
++ if (prop->priv->label) { |
237 |
+ g_object_unref (prop->priv->label); |
238 |
+ } |
239 |
+ |
240 |
+@@ -575,8 +572,10 @@ ibus_property_set_label (IBusProperty *prop, |
241 |
+ prop->priv->label = ibus_text_new_from_static_string (""); |
242 |
+ } |
243 |
+ else { |
244 |
+- prop->priv->label = g_object_ref_sink (label); |
245 |
++ prop->priv->label = label; |
246 |
+ } |
247 |
++ |
248 |
++ g_object_ref_sink (prop->priv->label); |
249 |
+ } |
250 |
+ |
251 |
+ void |
252 |
+@@ -586,7 +585,7 @@ ibus_property_set_symbol (IBusProperty *prop, |
253 |
+ g_assert (IBUS_IS_PROPERTY (prop)); |
254 |
+ g_return_if_fail (symbol == NULL || IBUS_IS_TEXT (symbol)); |
255 |
+ |
256 |
+- if (prop->priv->symbol && !ibus_text_get_is_static (prop->priv->symbol)) { |
257 |
++ if (prop->priv->symbol) { |
258 |
+ g_object_unref (prop->priv->symbol); |
259 |
+ } |
260 |
+ |
261 |
+@@ -594,8 +593,10 @@ ibus_property_set_symbol (IBusProperty *prop, |
262 |
+ prop->priv->symbol = ibus_text_new_from_static_string (""); |
263 |
+ } |
264 |
+ else { |
265 |
+- prop->priv->symbol = g_object_ref_sink (symbol); |
266 |
++ prop->priv->symbol = symbol; |
267 |
+ } |
268 |
++ |
269 |
++ g_object_ref_sink (prop->priv->symbol); |
270 |
+ } |
271 |
+ |
272 |
+ void |
273 |
+@@ -615,7 +616,7 @@ ibus_property_set_tooltip (IBusProperty *prop, |
274 |
+ g_assert (IBUS_IS_PROPERTY (prop)); |
275 |
+ g_assert (tooltip == NULL || IBUS_IS_TEXT (tooltip)); |
276 |
+ |
277 |
+- if (prop->priv->tooltip && !ibus_text_get_is_static (prop->priv->tooltip)) { |
278 |
++ if (prop->priv->tooltip) { |
279 |
+ g_object_unref (prop->priv->tooltip); |
280 |
+ } |
281 |
+ |
282 |
+@@ -624,8 +625,9 @@ ibus_property_set_tooltip (IBusProperty *prop, |
283 |
+ } |
284 |
+ else { |
285 |
+ prop->priv->tooltip = tooltip; |
286 |
+- g_object_ref_sink (prop->priv->tooltip); |
287 |
+ } |
288 |
++ |
289 |
++ g_object_ref_sink (prop->priv->tooltip); |
290 |
+ } |
291 |
+ |
292 |
+ void |
293 |
+-- |
294 |
+2.35.1 |
295 |
+ |
296 |
|
297 |
diff --git a/app-i18n/ibus/ibus-1.5.26.ebuild b/app-i18n/ibus/ibus-1.5.26-r1.ebuild |
298 |
similarity index 98% |
299 |
rename from app-i18n/ibus/ibus-1.5.26.ebuild |
300 |
rename to app-i18n/ibus/ibus-1.5.26-r1.ebuild |
301 |
index 93ead550b71b..40de7864df87 100644 |
302 |
--- a/app-i18n/ibus/ibus-1.5.26.ebuild |
303 |
+++ b/app-i18n/ibus/ibus-1.5.26-r1.ebuild |
304 |
@@ -77,6 +77,10 @@ BDEPEND=" |
305 |
nls? ( sys-devel/gettext ) |
306 |
unicode? ( app-i18n/unicode-data )" |
307 |
|
308 |
+PATCHES=( |
309 |
+ "${FILESDIR}"/${P}-src-Fix-refcounting-issues.patch |
310 |
+) |
311 |
+ |
312 |
src_prepare() { |
313 |
vala_src_prepare --ignore-use |
314 |
sed -i "/UCD_DIR=/s/\$with_emoji_annotation_dir/\$with_ucd_dir/" configure.ac |