Bug 76000 - [next] preparatory cleanup for GDBus migration
Summary: [next] preparatory cleanup for GDBus migration
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-glib (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: Simon McVittie
QA Contact: Telepathy bugs list
URL:
Whiteboard: review?
Keywords: patch
Depends on:
Blocks: 28782
  Show dependency treegraph
 
Reported: 2014-03-10 20:39 UTC by Simon McVittie
Modified: 2014-03-13 14:24 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
textchan-group: improve debug (1.64 KB, patch)
2014-03-10 20:40 UTC, Simon McVittie
Details | Splinter Review
Use concrete dbus-glib parameterized types, not G_TYPE_VALUE_ARRAY (2.30 KB, patch)
2014-03-10 20:40 UTC, Simon McVittie
Details | Splinter Review
TpContact: mime_file_written: don't leak the file's path (1.34 KB, patch)
2014-03-10 20:41 UTC, Simon McVittie
Details | Splinter Review
TpTestsContactsConnection: don't leak list_manager (1.24 KB, patch)
2014-03-10 20:41 UTC, Simon McVittie
Details | Splinter Review
Ignore allocations in gobject_init_ctor (646 bytes, patch)
2014-03-10 20:41 UTC, Simon McVittie
Details | Splinter Review
TpBaseContactList: don't leak groups hash table (790 bytes, patch)
2014-03-10 20:42 UTC, Simon McVittie
Details | Splinter Review
TpProxy: finish_all_requests: don't leak copied GQueue (668 bytes, patch)
2014-03-10 20:42 UTC, Simon McVittie
Details | Splinter Review
account test: don't leak copied strings (1.32 KB, patch)
2014-03-10 20:42 UTC, Simon McVittie
Details | Splinter Review
TpTestsSimpleChannelDispatcher: don't leak various struct members (2.10 KB, patch)
2014-03-10 20:42 UTC, Simon McVittie
Details | Splinter Review
cli-group test: don't leak GMainLoop (692 bytes, patch)
2014-03-10 20:42 UTC, Simon McVittie
Details | Splinter Review
channel-introspect test: enable debug-logging (773 bytes, patch)
2014-03-10 20:43 UTC, Simon McVittie
Details | Splinter Review
tests: extend timeout (730 bytes, patch)
2014-03-10 20:43 UTC, Simon McVittie
Details | Splinter Review
GDBus can deliver more than one event per main-loop iteration (6.44 KB, patch)
2014-03-10 20:44 UTC, Simon McVittie
Details | Splinter Review
dbus test: don't re-enter main loop to request/release names (3.83 KB, patch)
2014-03-10 20:45 UTC, Simon McVittie
Details | Splinter Review
invalidated-while-invoking-signals test: move to GTest (4.24 KB, patch)
2014-03-10 20:45 UTC, Simon McVittie
Details | Splinter Review
invalidated-while-invoking-signals test: extend test coverage (4.24 KB, patch)
2014-03-10 20:46 UTC, Simon McVittie
Details | Splinter Review
tp_tests_assert_last_unref: add (1.60 KB, patch)
2014-03-10 20:46 UTC, Simon McVittie
Details | Splinter Review

Description Simon McVittie 2014-03-10 20:39:29 UTC
While trying to make the tests pass, I accidentally some unrelated and semi-related fixes.
Comment 1 Simon McVittie 2014-03-10 20:40:06 UTC
Created attachment 95534 [details] [review]
textchan-group: improve debug
Comment 2 Simon McVittie 2014-03-10 20:40:25 UTC
Created attachment 95535 [details] [review]
Use concrete dbus-glib parameterized types, not  G_TYPE_VALUE_ARRAY

dbus_g_value_build_g_variant() doesn't yet understand how to build a
tuple from a G_TYPE_VALUE_ARRAY, so my branch to use GDBus for
everything will rely on using the full parameterized types.
Comment 3 Simon McVittie 2014-03-10 20:41:06 UTC
Created attachment 95536 [details] [review]
TpContact: mime_file_written: don't leak the file's  path

---

Might be a bugfix for master/stable also, I haven't checked. Could someone else? I'm busy shaving this yak.
Comment 4 Simon McVittie 2014-03-10 20:41:19 UTC
Created attachment 95537 [details] [review]
TpTestsContactsConnection: don't leak list_manager
Comment 5 Simon McVittie 2014-03-10 20:41:31 UTC
Created attachment 95538 [details] [review]
Ignore allocations in gobject_init_ctor
Comment 6 Simon McVittie 2014-03-10 20:42:04 UTC
Created attachment 95539 [details] [review]
TpBaseContactList: don't leak groups hash table

---

Not tested with any real CMs. Someone probably should before this reaches master, just to be safe.
Comment 7 Simon McVittie 2014-03-10 20:42:17 UTC
Created attachment 95540 [details] [review]
TpProxy: finish_all_requests: don't leak copied GQueue
Comment 8 Simon McVittie 2014-03-10 20:42:28 UTC
Created attachment 95541 [details] [review]
account test: don't leak copied strings
Comment 9 Simon McVittie 2014-03-10 20:42:41 UTC
Created attachment 95542 [details] [review]
TpTestsSimpleChannelDispatcher: don't leak various  struct members
Comment 10 Simon McVittie 2014-03-10 20:42:52 UTC
Created attachment 95543 [details] [review]
cli-group test: don't leak GMainLoop
Comment 11 Simon McVittie 2014-03-10 20:43:04 UTC
Created attachment 95544 [details] [review]
channel-introspect test: enable debug-logging
Comment 12 Simon McVittie 2014-03-10 20:43:20 UTC
Created attachment 95545 [details] [review]
tests: extend timeout

10 seconds is too short under valgrind, and this is only really
a safety-catch against never terminating.
Comment 13 Simon McVittie 2014-03-10 20:44:13 UTC
Created attachment 95546 [details] [review]
GDBus can deliver more than one event per main-loop  iteration

---

The comment

+   * We shouldn't assert len == 1 above because this happens automatically,
+   * and when we do a _run_ call, GDBus can give us than one
+   * event per main loop iteration (dbus-glib went to some lengths
+   * not to do so). */

should maybe move further up the file; or not.

This is the first of the commits that should maybe wait until we merge the GDBus branch.
Comment 14 Simon McVittie 2014-03-10 20:45:35 UTC
Created attachment 95547 [details] [review]
dbus test: don't re-enter main loop to request/release  names

GDBus guarantees that it will alternate signalling names appearing
and vanishing, and this reentrant usage probably breaks that.
It was a terrible idea anyway.

---

The commit message is maybe a little misleading. It still re-enters the main loop, but it re-enters in an idle, not in the name ownership change callback, which is less bad. I didn't really feel like rewriting this to use proper calls right now, the diffstat for this branch is terrifying anyway.
Comment 15 Simon McVittie 2014-03-10 20:45:47 UTC
Created attachment 95548 [details] [review]
invalidated-while-invoking-signals test: move to GTest
Comment 16 Simon McVittie 2014-03-10 20:46:01 UTC
Created attachment 95549 [details] [review]
invalidated-while-invoking-signals test: extend test  coverage

Since commit 6f153bca, we didn't wait for on_status_changed() to occur.
At some point it ceased to be reached at all, which meant that
commit db582a0d added an unbalanced unref for @client in what has
now become teardown(). If on_status_changed() was executed, it would
unref the client, and then the unref in teardown() would either be
a use-after-free or indirectly lead to one.

Porting telepathy-glib to GDBus exposed this bug, by making
on_status_changed() reachable again.

While fixing this I noticed that on_status_changed() is not guaranteed
to be the last-unref, so the test does not necessarily even reproduce
the original crash situation, which was the proxy being invalidated
inside the signal callback. I've addressed that by testing once with
the way the test has worked in practice since at least 2012, and
once with explicit forced invalidation.
Comment 17 Simon McVittie 2014-03-10 20:46:37 UTC
Created attachment 95551 [details] [review]
tp_tests_assert_last_unref: add

Some tests find this functionality useful.

---

I might omit this one if I discover that nothing actually needs it by the time I'm ready to land the GDBus branch.
Comment 18 Guillaume Desmottes 2014-03-12 10:13:02 UTC
Comment on attachment 95534 [details] [review]
textchan-group: improve debug

Review of attachment 95534 [details] [review]:
-----------------------------------------------------------------

++
Comment 19 Guillaume Desmottes 2014-03-12 10:13:25 UTC
Comment on attachment 95535 [details] [review]
Use concrete dbus-glib parameterized types, not  G_TYPE_VALUE_ARRAY

Review of attachment 95535 [details] [review]:
-----------------------------------------------------------------

++
Comment 20 Guillaume Desmottes 2014-03-12 10:13:52 UTC
Comment on attachment 95536 [details] [review]
TpContact: mime_file_written: don't leak the file's  path

Review of attachment 95536 [details] [review]:
-----------------------------------------------------------------

++  master and stable too as well if needed.
Comment 21 Guillaume Desmottes 2014-03-12 10:14:04 UTC
Comment on attachment 95537 [details] [review]
TpTestsContactsConnection: don't leak list_manager

Review of attachment 95537 [details] [review]:
-----------------------------------------------------------------

++
Comment 22 Guillaume Desmottes 2014-03-12 10:14:16 UTC
Comment on attachment 95538 [details] [review]
Ignore allocations in gobject_init_ctor

Review of attachment 95538 [details] [review]:
-----------------------------------------------------------------

ok.
Comment 23 Guillaume Desmottes 2014-03-12 10:15:07 UTC
Comment on attachment 95539 [details] [review]
TpBaseContactList: don't leak groups hash table

Review of attachment 95539 [details] [review]:
-----------------------------------------------------------------

++ stable/master as well.
Comment 24 Guillaume Desmottes 2014-03-12 10:15:44 UTC
Comment on attachment 95540 [details] [review]
TpProxy: finish_all_requests: don't leak copied GQueue

Review of attachment 95540 [details] [review]:
-----------------------------------------------------------------

++ stable/master too.
Comment 25 Guillaume Desmottes 2014-03-12 10:16:17 UTC
Comment on attachment 95541 [details] [review]
account test: don't leak copied strings

Review of attachment 95541 [details] [review]:
-----------------------------------------------------------------

++
Comment 26 Guillaume Desmottes 2014-03-12 10:16:33 UTC
Comment on attachment 95542 [details] [review]
TpTestsSimpleChannelDispatcher: don't leak various  struct members

Review of attachment 95542 [details] [review]:
-----------------------------------------------------------------

++
Comment 27 Guillaume Desmottes 2014-03-12 10:16:41 UTC
Comment on attachment 95543 [details] [review]
cli-group test: don't leak GMainLoop

Review of attachment 95543 [details] [review]:
-----------------------------------------------------------------

++
Comment 28 Guillaume Desmottes 2014-03-12 10:20:45 UTC
Comment on attachment 95544 [details] [review]
channel-introspect test: enable debug-logging

Review of attachment 95544 [details] [review]:
-----------------------------------------------------------------

++
Comment 29 Guillaume Desmottes 2014-03-12 10:20:58 UTC
Comment on attachment 95545 [details] [review]
tests: extend timeout

Review of attachment 95545 [details] [review]:
-----------------------------------------------------------------

ok
Comment 30 Guillaume Desmottes 2014-03-12 10:21:40 UTC
Comment on attachment 95546 [details] [review]
GDBus can deliver more than one event per main-loop  iteration

Review of attachment 95546 [details] [review]:
-----------------------------------------------------------------

++
Comment 31 Guillaume Desmottes 2014-03-12 10:22:05 UTC
Comment on attachment 95547 [details] [review]
dbus test: don't re-enter main loop to request/release  names

Review of attachment 95547 [details] [review]:
-----------------------------------------------------------------

++
Comment 32 Guillaume Desmottes 2014-03-12 10:24:44 UTC
Comment on attachment 95548 [details] [review]
invalidated-while-invoking-signals test: move to GTest

Review of attachment 95548 [details] [review]:
-----------------------------------------------------------------

++
Comment 33 Guillaume Desmottes 2014-03-12 10:26:00 UTC
Comment on attachment 95551 [details] [review]
tp_tests_assert_last_unref: add

Review of attachment 95551 [details] [review]:
-----------------------------------------------------------------

++
Comment 34 Simon McVittie 2014-03-13 12:42:47 UTC
(In reply to comment #21)
> TpTestsContactsConnection: don't leak list_manager

This was in fact incorrect: in 0.22, create_channel_managers() returns the ref, leaving list_manager as a borrowed ref to something tracked by the base class. That seems poor style, but is valid.

It's possible that this changed between 0.22 and next.
Comment 35 Simon McVittie 2014-03-13 12:43:44 UTC
(In reply to comment #6)
> TpBaseContactList: don't leak groups hash table

In 0.22, this is OK, but redundant: the same function already does a tp_clear_pointer(). Again, perhaps this changed between 0.22 and next.
Comment 36 Simon McVittie 2014-03-13 14:08:28 UTC
Comment on attachment 95534 [details] [review]
textchan-group: improve debug

0.99.8
Comment 37 Simon McVittie 2014-03-13 14:08:46 UTC
Comment on attachment 95535 [details] [review]
Use concrete dbus-glib parameterized types, not  G_TYPE_VALUE_ARRAY

0.99.8
Comment 38 Simon McVittie 2014-03-13 14:09:06 UTC
Comment on attachment 95536 [details] [review]
TpContact: mime_file_written: don't leak the file's  path

0.22.2, 0.23.3, 0.99.8
Comment 39 Simon McVittie 2014-03-13 14:09:27 UTC
Comment on attachment 95538 [details] [review]
Ignore allocations in gobject_init_ctor

0.99.8
Comment 40 Simon McVittie 2014-03-13 14:09:39 UTC
Comment on attachment 95540 [details] [review]
TpProxy: finish_all_requests: don't leak copied GQueue

0.22.2, 0.23.3, 0.99.8
Comment 41 Simon McVittie 2014-03-13 14:09:57 UTC
Comment on attachment 95541 [details] [review]
account test: don't leak copied strings

0.99.8
Comment 42 Simon McVittie 2014-03-13 14:10:30 UTC
Comment on attachment 95542 [details] [review]
TpTestsSimpleChannelDispatcher: don't leak various  struct members

0.99.8
Comment 43 Simon McVittie 2014-03-13 14:10:47 UTC
Comment on attachment 95543 [details] [review]
cli-group test: don't leak GMainLoop

0.99.8
Comment 44 Simon McVittie 2014-03-13 14:11:03 UTC
Comment on attachment 95544 [details] [review]
channel-introspect test: enable debug-logging

0.99.8
Comment 45 Simon McVittie 2014-03-13 14:11:17 UTC
Comment on attachment 95545 [details] [review]
tests: extend timeout

0.99.8
Comment 46 Simon McVittie 2014-03-13 14:12:10 UTC
Comment on attachment 95546 [details] [review]
GDBus can deliver more than one event per main-loop  iteration

0.99.8
Comment 47 Simon McVittie 2014-03-13 14:12:27 UTC
Comment on attachment 95547 [details] [review]
dbus test: don't re-enter main loop to request/release  names

0.99.8
Comment 48 Simon McVittie 2014-03-13 14:12:56 UTC
Comment on attachment 95548 [details] [review]
invalidated-while-invoking-signals test: move to GTest

0.99.8
Comment 49 Simon McVittie 2014-03-13 14:13:09 UTC
Comment on attachment 95549 [details] [review]
invalidated-while-invoking-signals test: extend test  coverage

0.99.8
Comment 50 Simon McVittie 2014-03-13 14:13:25 UTC
Comment on attachment 95551 [details] [review]
tp_tests_assert_last_unref: add

0.99.8
Comment 51 Simon McVittie 2014-03-13 14:21:53 UTC
(In reply to comment #35)
> (In reply to comment #6)
> > TpBaseContactList: don't leak groups hash table
> 
> In 0.22, this is OK, but redundant: the same function already does a
> tp_clear_pointer(). Again, perhaps this changed between 0.22 and next.

It did. It regressed in b91113d2 during early 'next' development.

Fixed in git for 0.99.8.
Comment 52 Simon McVittie 2014-03-13 14:24:21 UTC
(In reply to comment #34)
> (In reply to comment #21)
> > TpTestsContactsConnection: don't leak list_manager
> 
> This was in fact incorrect: in 0.22, create_channel_managers() returns the
> ref, leaving list_manager as a borrowed ref to something tracked by the base
> class. That seems poor style, but is valid.
> 
> It's possible that this changed between 0.22 and next.

Yes it did, when the base contact list ceased to be a channel manager, turning this weird memory management into a leak.

Fixed in git for 0.99.8.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.