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 615437 - totem segfaults on activating python plugins when pygtk can't be found
totem segfaults on activating python plugins when pygtk can't be found
Status: RESOLVED FIXED
Product: totem
Classification: Core
Component: Plugins
2.30.x
Other Linux
: Normal normal
: ---
Assigned To: General Totem maintainer(s)
General Totem maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2010-04-11 12:18 UTC by Hagen Fürstenau
Modified: 2010-04-14 12:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch fixing initialization check (910 bytes, patch)
2010-04-11 12:19 UTC, Hagen Fürstenau
needs-work Details | Review
backtrace of segfault (2.08 KB, text/plain)
2010-04-13 18:06 UTC, Hagen Fürstenau
  Details
revised patch (1.05 KB, patch)
2010-04-13 18:07 UTC, Hagen Fürstenau
none Details | Review
Fix possible crasher when PyGTK isn't available (2.78 KB, patch)
2010-04-14 12:39 UTC, Bastien Nocera
committed Details | Review

Description Hagen Fürstenau 2010-04-11 12:18:24 UTC
This is easiest to reproduce by moving "pygtk.*" away from your Python search path, so that "import pygtk" results in an ImportError. totem then crashes on activating Python plugins. If any were activated before, it segfaults immediately on startup.

The issue is not hypothetical and has come up under different circumstances in https://bugs.launchpad.net/ubuntu/+bug/367573.

The problem is in "totem-python-module.c", where "totem_python_module_load" relies on Py_IsInitialized(), which is too optimistic, leading to the segfault.

Simple patch is attached.
Comment 1 Hagen Fürstenau 2010-04-11 12:19:24 UTC
Created attachment 158419 [details] [review]
patch fixing initialization check
Comment 2 Bastien Nocera 2010-04-13 15:34:57 UTC
Review of attachment 158419 [details] [review]:

What exactly crashes? It seems to me that it would "crash" in:
main_module = PyImport_AddModule ("__main__");
which would be because fatal warnings are enabled.

Please provide a full backtrace with debuginfo available.

::: src/plugins/totem-python-module.c
@@ +65,3 @@
 };
 
+int python_initialized = 0;

Use a gboolean, comment what it's used for.

@@ +268,3 @@
 	 * do any clean-up at this point, we'll just skip this as well */
 	PyEval_SaveThread();
+	python_initialized = 1;

Add a new line before that, it has nothing to do with the chunk of code and the comment above it.
Comment 3 Hagen Fürstenau 2010-04-13 18:06:32 UTC
Created attachment 158627 [details]
backtrace of segfault
Comment 4 Hagen Fürstenau 2010-04-13 18:07:22 UTC
Actually it already segfaults at the call to "pyg_gil_state_ensure", see attached backtrace. I also revised the patch.
Comment 5 Hagen Fürstenau 2010-04-13 18:07:49 UTC
Created attachment 158629 [details] [review]
revised patch
Comment 6 Bastien Nocera 2010-04-14 12:39:12 UTC
Created attachment 158711 [details] [review]
Fix possible crasher when PyGTK isn't available

If PyGTK is available at compile-time, but not available at run-time,
then we shouldn't try to call pyg_gil_state_ensure() as it would crash.

Print errors and disable Python support if PyGTK isn't available.
Comment 7 Bastien Nocera 2010-04-14 12:40:53 UTC
Committed with some style changes, and more warnings.