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 620062 - Python thread support is broken
Python thread support is broken
Status: RESOLVED FIXED
Product: libpeas
Classification: Platform
Component: python
git master
Other Linux
: Normal normal
: ---
Assigned To: libpeas-maint
libpeas-maint
Depends on:
Blocks: 622963
 
 
Reported: 2010-05-30 00:38 UTC by Steve Frécinaux
Modified: 2010-06-28 13:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[Python] Fix thread support. (4.36 KB, patch)
2010-06-14 16:48 UTC, Steve Frécinaux
none Details | Review
Fix thread support (updated) (7.85 KB, patch)
2010-06-27 17:47 UTC, Philip Withnall
reviewed Details | Review
Fix thread support (updated again) (8.20 KB, patch)
2010-06-27 22:24 UTC, Philip Withnall
committed Details | Review

Description Steve Frécinaux 2010-05-30 00:38:33 UTC
We should fix this, as it was done in totem and gedit.
Comment 1 Ignacio Casal Quinteiro (nacho) 2010-06-01 22:34:24 UTC
http://git.gnome.org/browse/gedit/commit/?id=327384762b548bd80588cef9de2baa32a5c30a0a

gedit fix.
Comment 2 Steve Frécinaux 2010-06-02 18:22:00 UTC
Wanna port it over to libpeas ? ;-)
Comment 3 Steve Frécinaux 2010-06-14 16:48:14 UTC
Created attachment 163609 [details] [review]
[Python] Fix thread support.
Comment 4 Philip Withnall 2010-06-27 17:24:38 UTC
Running Totem with one Python plugin (pythonconsole, which is non-threaded) enabled with attachment #163609 [details] applies to libpeas master gave the following crash:

** (totem:18955): WARNING **: Error opening directory '/home/philip/.local/share/totem/plugins': No such file or directory
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/skipto/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/pythonconsole/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/thumbnail/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/brasero-disc-recorder/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/opensubtitles/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/screenshot/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/youtube/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/sample-python/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/ontop/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/media-player-keys/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/jamendo/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/iplayer/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/sample-vala/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/coherence_upnp/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/gromit/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/dbus/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/screensaver/*.totem-plugin...
** (totem:18955): DEBUG: Loading /opt/gnome2/build/lib64/totem/plugins/properties/*.totem-plugin...
Totem-Message: totem_plugins_engine_load_all
Totem-Message: checking peas_plugin_info_get_module_name (info) movie-properties
Totem-Message: peas_plugin_info_get_module_name (info) movie-properties, to activate
Totem-Message: checking peas_plugin_info_get_module_name (info) screensaver
Totem-Message: peas_plugin_info_get_module_name (info) screensaver, to activate
Totem-Message: checking peas_plugin_info_get_module_name (info) dbus-service
Totem-Message: checking peas_plugin_info_get_module_name (info) gromit
Totem-Message: checking peas_plugin_info_get_module_name (info) coherence_upnp
Totem-Message: checking peas_plugin_info_get_module_name (info) sample-vala
Totem-Message: checking peas_plugin_info_get_module_name (info) iplayer
Totem-Message: checking peas_plugin_info_get_module_name (info) jamendo
Totem-Message: checking peas_plugin_info_get_module_name (info) media_player_keys
Totem-Message: peas_plugin_info_get_module_name (info) media_player_keys, to activate
Totem-Message: checking peas_plugin_info_get_module_name (info) ontop
Totem-Message: checking peas_plugin_info_get_module_name (info) sample-python
Totem-Message: checking peas_plugin_info_get_module_name (info) youtube
Totem-Message: peas_plugin_info_get_module_name (info) youtube, to activate
Totem-Message: checking peas_plugin_info_get_module_name (info) screenshot
Totem-Message: peas_plugin_info_get_module_name (info) screenshot, to activate
Totem-Message: checking peas_plugin_info_get_module_name (info) opensubtitles
Totem-Message: checking peas_plugin_info_get_module_name (info) brasero-disc-recorder
Totem-Message: checking peas_plugin_info_get_module_name (info) thumbnail
Totem-Message: checking peas_plugin_info_get_module_name (info) pythonconsole
Totem-Message: peas_plugin_info_get_module_name (info) pythonconsole, to activate
Totem-Message: checking peas_plugin_info_get_module_name (info) skipto
Totem-Message: peas_plugin_info_get_module_name (info) skipto, to activate
** (totem:18955): DEBUG: Loading loader 'c': '/opt/gnome2/build/lib64/libpeas-1.0/loaders/libcloader.so'
** (totem:18955): DEBUG: Registered extension for type 'PeasPluginLoader'
** (totem:18955): DEBUG: Insert module movie-properties into C module set
** (totem:18955): DEBUG: Registered extension for type 'PeasActivatable'
** (totem:18955): DEBUG: Insert module screensaver into C module set
** (totem:18955): DEBUG: Registered extension for type 'PeasActivatable'
[New Thread 0x7fffe2f66710 (LWP 18965)]
** (totem:18955): DEBUG: Insert module media_player_keys into C module set
** (totem:18955): DEBUG: Registered extension for type 'PeasActivatable'
** (totem:18955): DEBUG: Insert module youtube into C module set
** (totem:18955): DEBUG: Registered extension for type 'PeasActivatable'
** (totem:18955): DEBUG: Insert module screenshot into C module set
** (totem:18955): DEBUG: Registered extension for type 'PeasActivatable'
** (totem:18955): DEBUG: Loading loader 'python': '/opt/gnome2/build/lib64/libpeas-1.0/loaders/libpythonloader.so'
** (totem:18955): DEBUG: Registered extension for type 'PeasPluginLoader'
** (totem:18955): DEBUG: Adding /opt/gnome2/build/lib64/totem/plugins/python as a module path for the python loader.

Program received signal SIGSEGV, Segmentation fault.
0x0000003b18b00b3d in PySys_GetObject (name=0x7fffda2d1edf "path") at Python/sysmodule.c:53
53		PyObject *sd = tstate->interp->sysdict;
Missing separate debuginfos, use: debuginfo-install alsa-plugins-pulseaudio-1.0.22-1.fc13.x86_64 libffi-3.0.9-1.fc13.x86_64 libuuid-2.17.2-5.fc13.x86_64
(gdb) t a a bt

Thread 1 (Thread 0x7ffff2c01920 (LWP 18955))

  • #0 PySys_GetObject
    at Python/sysmodule.c line 53
  • #1 peas_plugin_loader_python_add_module_path
    at peas-plugin-loader-python.c line 374
  • #2 peas_plugin_loader_python_add_module_directory
    at peas-plugin-loader-python.c line 232
  • #3 peas_plugin_loader_add_module_directory
    at peas-plugin-loader.c line 47
  • #4 load_plugin_loader
    at peas-engine.c line 541
  • #5 get_plugin_loader
    at peas-engine.c line 572
  • #6 load_plugin
    at peas-engine.c line 665
  • #7 peas_engine_load_plugin_real
    at peas-engine.c line 691
  • #8 g_cclosure_marshal_VOID__BOXED
    at gmarshal.c line 568
  • #9 g_type_class_meta_marshal
    at gclosure.c line 878
  • #10 g_closure_invoke
    at gclosure.c line 767
  • #11 signal_emit_unlocked_R
    at gsignal.c line 3291
  • #12 g_signal_emit_valist
    at gsignal.c line 2984
  • #13 g_signal_emit
    at gsignal.c line 3041
  • #14 peas_engine_set_loaded_plugins
    at peas-engine.c line 866
  • #15 totem_plugins_engine_load_all
    at plugins/totem-plugins-engine.c line 146
  • #16 totem_plugins_engine_get_default
    at plugins/totem-plugins-engine.c line 239
  • #17 totem_object_plugins_init
    at totem-object.c line 337
  • #18 main
    at totem.c line 333

Comment 5 Philip Withnall 2010-06-27 17:26:37 UTC
(Should've mentioned: it crashed because tstate was NULL in frame #0.)
Comment 6 Philip Withnall 2010-06-27 17:47:38 UTC
Created attachment 164759 [details] [review]
Fix thread support (updated)

Turns out that there were just a few GIL grabs missing from various bits of the loader. With this patch applied, Totem and its threaded plugins run fine.
Comment 7 Steve Frécinaux 2010-06-27 19:38:06 UTC
Review of attachment 164759 [details] [review]:

Philip, could you rebase this patch? It doesn't apply anymore already.

You can put your own name and email (actually I would prefer), I don't consider myself as the author of it because my non-working patch was just a straight untested port of the old gedit one.

::: loaders/python/peas-plugin-loader-python.c
@@ +400,1 @@
   return TRUE;

Please do not remove this empty line

@@ +502,3 @@
   loader->priv->init_failed = FALSE;
 
+  loader->priv->py_thread_state = PyEval_SaveThread ();

Is this required? It turns out we never use that value later, so maybe we can just remove this.
Comment 8 Philip Withnall 2010-06-27 22:24:43 UTC
Created attachment 164771 [details] [review]
Fix thread support (updated again)
Comment 9 Philip Withnall 2010-06-27 22:25:44 UTC
(In reply to comment #7)
> @@ +502,3 @@
>    loader->priv->init_failed = FALSE;
> 
> +  loader->priv->py_thread_state = PyEval_SaveThread ();
> 
> Is this required? It turns out we never use that value later, so maybe we can
> just remove this.

Looking back at the origin gedit diff, the libpeas patch was missing the matching call to PyEval_RestoreThread(). I've added it, and everything's working nicely as far as I can tell.
Comment 10 Steve Frécinaux 2010-06-28 08:56:06 UTC
Review of attachment 164771 [details] [review]:

It looks okay. Feel free to push it into master.