After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 705289 - Crash when removing an individual with 2 aggregators instantiated
Crash when removing an individual with 2 aggregators instantiated
Status: RESOLVED FIXED
Product: folks
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: Unset
Assigned To: folks-maint
folks-maint
Depends on:
Blocks:
 
 
Reported: 2013-08-01 13:45 UTC by Guillaume Desmottes
Modified: 2013-08-05 12:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add unit test for bgo#705289 (5.31 KB, patch)
2013-08-01 13:46 UTC, Guillaume Desmottes
accepted-commit_now Details | Review
add unit test for bgo#705289 (6.72 KB, patch)
2013-08-02 10:46 UTC, Guillaume Desmottes
accepted-commit_now Details | Review
add unit test for bgo#705289 (6.69 KB, patch)
2013-08-02 11:04 UTC, Guillaume Desmottes
committed Details | Review
Debug log (37.18 KB, text/x-log)
2013-08-02 14:18 UTC, Philip Withnall
  Details
aggregator: add dup() method returning a singleton (4.21 KB, patch)
2013-08-05 09:24 UTC, Guillaume Desmottes
needs-work Details | Review
Revert "add unit test for bgo#705289" (6.90 KB, patch)
2013-08-05 09:24 UTC, Guillaume Desmottes
committed Details | Review
aggregator: add dup() methods returning a singleton (6.32 KB, patch)
2013-08-05 12:18 UTC, Guillaume Desmottes
committed Details | Review
tests: use IndividualAggregator.dup () (69.71 KB, patch)
2013-08-05 12:35 UTC, Guillaume Desmottes
none Details | Review
use IndividualAggregator.dup () in tests and tools (70.91 KB, patch)
2013-08-05 12:41 UTC, Guillaume Desmottes
committed Details | Review

Description Guillaume Desmottes 2013-08-01 13:45:30 UTC
See the attached unit test. It works fine if I don't instantiate _aggregator2 and call _unlink_individuals() right away. I don't think I'm doing anything wrong here so I suspect Folks doesn't play nice when we have more than once aggregator instantiated.

(/home/cassidy/dev/tizen-pc/folks/tests/eds/.libs/lt-unlink-double-aggregator:16838): folks-WARNING **: Link map contains invalid mapping:
    test:pas-id-51FA65C200000000 → e1c80aab7c00163f1a50f2c2ca922187995ddaca (0x1cd45a0)
  • #0 waitpid
    from /lib64/libpthread.so.0
  • #1 g_on_error_stack_trace
  • #2 _folks_test_case_log_adaptor_log_func_stack_trace
  • #3 __folks_test_case_log_adaptor_log_func_stack_trace_glog_func
  • #4 g_logv
  • #5 g_log
  • #6 _folks_individual_aggregator_personas_changed_cb
  • #7 _folks_individual_aggregator_persona_anti_links_changed_cb
  • #8 __folks_individual_aggregator_persona_anti_links_changed_cb_g_object_notify
  • #9 g_cclosure_marshal_VOID__PARAM
  • #10 g_closure_invoke
  • #11 signal_emit_unlocked_R
  • #12 g_signal_emit_valist
  • #13 g_signal_emit
  • #14 g_object_dispatch_properties_changed
  • #15 g_object_notify_queue_thaw
  • #16 g_object_thaw_notify
  • #17 _edsf_persona_update
  • #18 _edsf_persona_store_contacts_changed_idle
  • #19 __lambda6_
  • #20 ___lambda6__gsource_func
  • #21 _edsf_persona_store_idle_process
  • #22 __edsf_persona_store_idle_process_gsource_func
  • #23 g_idle_dispatch
  • #24 g_main_dispatch
    at gmain.c line 3054
  • #25 g_main_context_dispatch
  • #26 g_main_context_iterate
  • #27 g_main_loop_run
    at gmain.c line 3895
  • #28 folks_test_utils_loop_run_with_timeout
  • #29 unlink_double_aggregator_test_test_unlink_double_aggregator
  • #30 _unlink_double_aggregator_test_test_unlink_double_aggregator_folks_test_case_test_method
  • #31 folks_test_case_weak_method_test
  • #32 test_case_run
    at gtestutils.c line 1714
  • #33 g_test_run_suite_internal
  • #34 g_test_run_suite_internal
  • #35 g_test_run_suite
  • #36 g_test_run
    at gtestutils.c line 1324
  • #37 _vala_main
  • #38 main

Comment 1 Guillaume Desmottes 2013-08-01 13:46:29 UTC
Created attachment 250621 [details] [review]
add unit test for bgo#705289

Change-Id: I48adbd4acc7cf25a6daff3c61a4357873b8df398
Comment 2 Guillaume Desmottes 2013-08-01 14:08:01 UTC
Note that if we remove the individual instead of unlinking we trigger another crash.

-          yield this._aggregator.unlink_individual(individuals[0]);
+          yield this._aggregator.remove_individual(individuals[0]);


folks:ERROR:/home/cassidy/dev/tizen-pc/folks/folks/individual.vala:2476:_folks_individual_set_personas: assertion failed: (replacement_individual == null || replacement_individual != this)
  • #0 waitpid
    from /lib64/libpthread.so.0
  • #1 g_on_error_stack_trace
  • #2 _folks_test_case_log_adaptor_printerr_func_stack_trace
  • #3 __folks_test_case_log_adaptor_printerr_func_stack_trace_gprint_func
  • #4 g_printerr
  • #5 g_assertion_message
  • #6 g_assertion_message_expr
  • #7 _folks_individual_set_personas
  • #8 folks_individual_replace
  • #9 _folks_individual_aggregator_personas_changed_cb
  • #11 g_cclosure_user_marshal_VOID__OBJECT_OBJECT_STRING_OBJECT_ENUM
  • #12 g_closure_invoke
  • #13 signal_emit_unlocked_R
  • #14 g_signal_emit_valist
  • #15 g_signal_emit_by_name
  • #16 _folks_persona_store_emit_personas_changed
  • #17 _edsf_persona_store_contacts_removed_idle
  • #18 __lambda5_
  • #19 ___lambda5__gsource_func
  • #20 _edsf_persona_store_idle_process
  • #21 __edsf_persona_store_idle_process_gsource_func
  • #22 g_idle_dispatch
  • #23 g_main_dispatch
    at gmain.c line 3054
  • #24 g_main_context_dispatch
  • #25 g_main_context_iterate
  • #26 g_main_loop_run
    at gmain.c line 3895
  • #27 folks_test_utils_loop_run_with_timeout
  • #28 unlink_double_aggregator_test_test_unlink_double_aggregator
  • #29 _unlink_double_aggregator_test_test_unlink_double_aggregator_folks_test_case_test_method
  • #30 folks_test_case_weak_method_test
  • #31 test_case_run
    at gtestutils.c line 1714
  • #32 g_test_run_suite_internal
  • #33 g_test_run_suite_internal
  • #34 g_test_run_suite
  • #35 g_test_run
    at gtestutils.c line 1324
  • #36 _vala_main
  • #37 main

Comment 3 Philip Withnall 2013-08-02 07:13:54 UTC
Review of attachment 250621 [details] [review]:

Looks useful. Please commit after fixing the minor comments below. I’ll look into the crash itself later.

::: tests/eds/unlink-double-aggregator.vala
@@ +65,3 @@
+      try
+         {
+           yield aggregator.prepare();

Missing space before ‘()’, and in a few other places in the file.

@@ +69,3 @@
+       catch (GLib.Error e)
+         {
+           GLib.warning ("Error when calling prepare: %s\n", e.message);

This should be a GLib.error().

@@ +78,3 @@
+
+      this._aggregator.notify["is-quiescent"].connect (this._link_individuals);
+      _prepare_aggregator(this._aggregator);

‘this._prepare_aggregator (this._aggregator)’.

@@ +98,3 @@
+      catch (GLib.Error e)
+        {
+          GLib.warning ("link_personas: %s\n", e.message);

This should be a GLib.error() as well.

@@ +122,3 @@
+      catch (GLib.Error e)
+        {
+          GLib.warning ("unlink_individual: %s\n", e.message);

This should also be a GLib.error().
Comment 4 Guillaume Desmottes 2013-08-02 08:16:37 UTC
(In reply to comment #3)
> Review of attachment 250621 [details] [review]:
> 
> Looks useful. Please commit after fixing the minor comments below. I’ll look
> into the crash itself later.

Should I really commit it without the fix? That will break "make check".

> ::: tests/eds/unlink-double-aggregator.vala
> @@ +65,3 @@
> +      try
> +         {
> +           yield aggregator.prepare();
> 
> Missing space before ‘()’, and in a few other places in the file.

Fixed.

> @@ +69,3 @@
> +       catch (GLib.Error e)
> +         {
> +           GLib.warning ("Error when calling prepare: %s\n", e.message);
> 
> This should be a GLib.error().

done.

> @@ +78,3 @@
> +
> +      this._aggregator.notify["is-quiescent"].connect
> (this._link_individuals);
> +      _prepare_aggregator(this._aggregator);
> 
> ‘this._prepare_aggregator (this._aggregator)’.

done.

> @@ +98,3 @@
> +      catch (GLib.Error e)
> +        {
> +          GLib.warning ("link_personas: %s\n", e.message);
> 
> This should be a GLib.error() as well.
>
done.

> @@ +122,3 @@
> +      catch (GLib.Error e)
> +        {
> +          GLib.warning ("unlink_individual: %s\n", e.message);
> 
> This should also be a GLib.error().

done.
Comment 5 Guillaume Desmottes 2013-08-02 10:46:14 UTC
Created attachment 250679 [details] [review]
add unit test for bgo#705289

https://bugzilla.gnome.org/show_bug.cgi?id=705289

Change-Id: Ief7bef8651ae1df8b2a927ae22fd5fb162e43466
Comment 6 Guillaume Desmottes 2013-08-02 10:47:22 UTC
For some reason I can no longer reproduce the 'unlink error', even using the old test?!

Anyway, here is an updated test reproducing the 'remove' error (which was the one I was trying to reproduce).
Comment 7 Philip Withnall 2013-08-02 10:56:27 UTC
Review of attachment 250679 [details] [review]:

Looks good. Please commit with the change below. Thanks.

::: tests/eds/Makefile.am
@@ +84,3 @@
 	set-is-favourite \
 	perf \
+	double-aggregator \

Move this a bit higher up TESTS, since they’re ordered by increasing complexity (i.e. increasing likelihood of failure).
Comment 8 Guillaume Desmottes 2013-08-02 11:04:53 UTC
Created attachment 250680 [details] [review]
add unit test for bgo#705289

https://bugzilla.gnome.org/show_bug.cgi?id=705289

Change-Id: Ief7bef8651ae1df8b2a927ae22fd5fb162e43466
Comment 9 Guillaume Desmottes 2013-08-02 11:07:10 UTC
Comment on attachment 250680 [details] [review]
add unit test for bgo#705289

Attachment 250680 [details] pushed as 1b7e8d8 - add unit test for bgo#705289
Comment 10 Philip Withnall 2013-08-02 14:18:21 UTC
Created attachment 250704 [details]
Debug log

Log generated using:
    FOLKS_DEBUG=all G_MESSAGES_DEBUG=all make check TESTS=double-aggregator CHECK_VERBOSE=1
Comment 11 Philip Withnall 2013-08-02 14:37:28 UTC
As mentioned on IRC, I think this is because the two IA instances create separate Individuals which use the same Personas (because the IAs share PersonaStore instances). The IAs can then get cross-over between their sets of Individuals by following the Persona.individual pointers, which could result in one IA using Individuals created by the other in its aggregation calculations, and hence exploding.

Unless you’ve got a really good use-case for using multiple IA instances in a single process, I’m very inclined to explicitly document this as unsupported, and require that IndividualAggregator be a singleton. Without having looked too deeply into it, I suspect that supporting multiple IAs in a single process will be quite complex, and the aggregator code’s complex enough already.
Comment 12 Guillaume Desmottes 2013-08-03 11:44:16 UTC
Yeah that was my conclusion from my investigations as well.

I think it's fine to claim that multiple IA aren't supported but then we should enforce this behaviour but forcing the IA implementation as a singleton (_new() would return a ref on an existing instance if any). Would you be ok with such change?

Btw, I'm not supposed to have multiple IA instance either, but I end up with 2 because of JS/Seed's garbage collector being weird/buggy, leading me to this crash.
Comment 13 Philip Withnall 2013-08-04 12:29:20 UTC
(In reply to comment #12)
> Yeah that was my conclusion from my investigations as well.
> 
> I think it's fine to claim that multiple IA aren't supported but then we should
> enforce this behaviour but forcing the IA implementation as a singleton (_new()
> would return a ref on an existing instance if any). Would you be ok with such
> change?

Sounds good to me. The documentation would need updating as well, and your test case commit would need reverting.

> Btw, I'm not supposed to have multiple IA instance either, but I end up with 2
> because of JS/Seed's garbage collector being weird/buggy, leading me to this
> crash.

Do you think that’s potentially a bug in folks, or just JS?
Comment 14 Guillaume Desmottes 2013-08-05 09:24:41 UTC
Created attachment 250839 [details] [review]
aggregator: add dup() method returning a singleton

As discussed on bgo#705289 we don't support having different aggregator
instances as they would share the same set of personas. Adding this singleton
makes things easier for client applications.
Comment 15 Guillaume Desmottes 2013-08-05 09:24:49 UTC
Created attachment 250840 [details] [review]
Revert "add unit test for bgo#705289"

It doesn't make sense any more as multiple aggregators are not supported any
more.

This reverts commit 1b7e8d83bb7488aac7bcf2d59df3a7b35f316ae2.
Comment 16 Philip Withnall 2013-08-05 10:50:06 UTC
Review of attachment 250839 [details] [review]:

::: folks/individual-aggregator.vala
@@ +372,3 @@
+   * instantiated at the same time. So it's recommended to use
+   * {@link IndividualAggregator.dup} if you need to instantiate it more than
+   * once.

This constructor should be deprecated (and that should be mentioned in NEWS).

I think you should also deprecate .with_backend_store() and instead add a new static .dup_with_backend_store() which has the behaviour we discussed on IRC (i.e. it creates a new IA with the given backend store if (_instance == null), but returns null if (_instance != null && _instance.backend_store != backend_store)).

Because of the deprecations, all the folks tests should be ported to use the .dup() constructor. That can be a separate commit.
Comment 17 Philip Withnall 2013-08-05 10:51:04 UTC
Review of attachment 250840 [details] [review]:

Please commit to master immediately. :-)
Comment 18 Guillaume Desmottes 2013-08-05 12:18:53 UTC
Created attachment 250863 [details] [review]
aggregator: add dup() methods returning a singleton

As discussed on bgo#705289 we don't support having different aggregator
instances as they would share the same set of personas. Adding this singleton
makes things easier for client applications.
Comment 19 Guillaume Desmottes 2013-08-05 12:35:09 UTC
Created attachment 250865 [details] [review]
tests: use IndividualAggregator.dup ()

The default constructor has been deprecated.
Comment 20 Philip Withnall 2013-08-05 12:35:59 UTC
Review of attachment 250863 [details] [review]:

Looks good. Don’t forget to mention this bug under “Bugs fixed” in NEWS. Thanks!
Comment 21 Guillaume Desmottes 2013-08-05 12:41:08 UTC
Created attachment 250866 [details] [review]
use IndividualAggregator.dup () in tests and tools

The default constructor has been deprecated.
Comment 22 Philip Withnall 2013-08-05 12:48:08 UTC
Review of attachment 250866 [details] [review]:

Go go go!
Comment 23 Guillaume Desmottes 2013-08-05 12:49:48 UTC
Attachment 250863 [details] pushed as ed8e377 - aggregator: add dup() methods returning a singleton
Attachment 250866 [details] pushed as 4322477 - use IndividualAggregator.dup () in tests and tools