GNOME Bugzilla – Bug 615437
totem segfaults on activating python plugins when pygtk can't be found
Last modified: 2010-04-14 12:40:53 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.
Created attachment 158419 [details] [review] patch fixing initialization check
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.
Created attachment 158627 [details] backtrace of segfault
Actually it already segfaults at the call to "pyg_gil_state_ensure", see attached backtrace. I also revised the patch.
Created attachment 158629 [details] [review] revised patch
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.
Committed with some style changes, and more warnings.