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 739619 - Make libpeas thread-safe
Make libpeas thread-safe
Status: RESOLVED FIXED
Product: libpeas
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: libpeas-maint
libpeas-maint
Depends on:
Blocks:
 
 
Reported: 2014-11-04 14:15 UTC by Garrett Regier
Modified: 2014-11-18 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make the plugin loaders thread-safe (26.84 KB, patch)
2014-11-04 16:41 UTC, Garrett Regier
none Details | Review
Make the C plugin loader thread-safe (8.30 KB, patch)
2014-11-08 20:35 UTC, Garrett Regier
committed Details | Review
Make the Python plugin loader thread-safe (16.49 KB, patch)
2014-11-08 20:35 UTC, Garrett Regier
committed Details | Review
Document that the lua5.1 plugin loader is not thread-safe (1.03 KB, patch)
2014-11-08 20:36 UTC, Garrett Regier
committed Details | Review
Make PeasEngine thread-safe (18.52 KB, patch)
2014-11-08 20:36 UTC, Garrett Regier
accepted-commit_now Details | Review
Add an extension test that uses multiple threads (8.77 KB, patch)
2014-11-08 20:36 UTC, Garrett Regier
committed Details | Review
Make PeasEngine thread-safe v2 (18.48 KB, patch)
2014-11-16 20:27 UTC, Garrett Regier
committed Details | Review

Description Garrett Regier 2014-11-04 14:15:50 UTC
The main advantage of this would be to allow each PeasEngine to be used from a separate thread for performance reasons.
Comment 1 Garrett Regier 2014-11-04 16:41:12 UTC
Created attachment 289981 [details] [review]
Make the plugin loaders thread-safe

This is required for making PeasEngine thread-safe.

Only makes the C and Python loaders thread-safe, the Lua plugin loader will use a GRecMutex but has not been included in this patch as it has not been included into git master yet.
Comment 2 Garrett Regier 2014-11-08 20:35:35 UTC
Created attachment 290235 [details] [review]
Make the C plugin loader thread-safe
Comment 3 Garrett Regier 2014-11-08 20:35:50 UTC
Created attachment 290236 [details] [review]
Make the Python plugin loader thread-safe
Comment 4 Garrett Regier 2014-11-08 20:36:04 UTC
Created attachment 290237 [details] [review]
Document that the lua5.1 plugin loader is not thread-safe
Comment 5 Garrett Regier 2014-11-08 20:36:19 UTC
Created attachment 290238 [details] [review]
Make PeasEngine thread-safe
Comment 6 Garrett Regier 2014-11-08 20:36:49 UTC
Created attachment 290239 [details] [review]
Add an extension test that uses multiple threads

This should act as a good stress test for checking that libpeas is thread-safe.

This also changes testing-utils to be thread aware.
Comment 7 Ignacio Casal Quinteiro (nacho) 2014-11-13 08:44:57 UTC
Review of attachment 290235 [details] [review]:

Seems fine to me.
Comment 8 Ignacio Casal Quinteiro (nacho) 2014-11-13 08:47:11 UTC
Review of attachment 290236 [details] [review]:

hard to review this one, but if you tested it go ahead.
Comment 9 Ignacio Casal Quinteiro (nacho) 2014-11-13 08:48:23 UTC
Review of attachment 290237 [details] [review]:

I am ok with this but why lua can't? should there be a comment somewhere in the lua loader?
Comment 10 Ignacio Casal Quinteiro (nacho) 2014-11-13 08:53:45 UTC
Review of attachment 290238 [details] [review]:

See the comment

::: libpeas/peas-engine.c
@@ +451,3 @@
+      LoaderInfo *loader_info = &engine->priv->loaders[i];
+
+      if (loader_info->loader != NULL)

no need for this check

@@ +1379,3 @@
  * of this function will return a new instance of #PeasEngine.
  *
+ * Note: this function should never be used when multiple threads are

I think it would be possible to make get_default thread safe but it would be a pita
Comment 11 Ignacio Casal Quinteiro (nacho) 2014-11-13 08:56:25 UTC
Review of attachment 290239 [details] [review]:

OK
Comment 12 Garrett Regier 2014-11-13 16:06:31 UTC
(In reply to comment #10)
> Review of attachment 290238 [details] [review]:
> 
> See the comment
> 
> ::: libpeas/peas-engine.c
> @@ +451,3 @@
> +      LoaderInfo *loader_info = &engine->priv->loaders[i];
> +
> +      if (loader_info->loader != NULL)
> 
> no need for this check
> 

Will do.

> @@ +1379,3 @@
>   * of this function will return a new instance of #PeasEngine.
>   *
> + * Note: this function should never be used when multiple threads are
> 
> I think it would be possible to make get_default thread safe but it would be a
> pita

It would be possible if it used a GPrivate, but because get_default() doesn't return a new ref it wouldn't work without it. But really I don't think get_default() should be called from a non-main thread as it is just asking for issues and it could break existing users. For example, as part of main() the engine is created but it is only used by another thread for the rest of the program and it uses get_default() to get the originally created engine. Suddenly things no longer work because get_default() from another thread causes a crash.
Comment 13 Garrett Regier 2014-11-13 16:14:58 UTC
(In reply to comment #9)
> Review of attachment 290237 [details] [review]:
> 
> I am ok with this but why lua can't? should there be a comment somewhere in the
> lua loader?

I will add a link to the issue I just created.

https://github.com/pavouk/lgi/issues/92
Comment 14 Garrett Regier 2014-11-14 19:29:08 UTC
Possible solution in LGI issue, will update the lua5.1 plugin loader as needed.

Should these just be merged until a solution is found? We have a few months until freeze...
Comment 15 Garrett Regier 2014-11-16 20:27:26 UTC
Created attachment 290813 [details] [review]
Make PeasEngine thread-safe v2
Comment 16 Garrett Regier 2014-11-18 18:40:30 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.