GNOME Bugzilla – Bug 334188
Segfault when using g_log after Py_Finalize is called
Last modified: 2006-04-01 18:20:28 UTC
Calling Py_Finalize() doesn't appear to remove the g_log handler the pygobject installs. Because of this, I'm getting a segfault if anything uses g_log after Py_Finalize if called, with the following backtrace:
+ Trace 66844
This is repeatable for me using Rhythmbox's new plugin stuff (based on Gedit's), if I re-enable the Py_Finalize call in rb-python-module.c and cause g_log to get used after that. I'll try to write a simpler test-case that makes it happen.
I don't think there's anything that uninstalls the log handler when Py_Finalize is called and the bug occurs when trying to call Python functions from here. There probably isn't a need for a simpler test-case to diagnose this, though one could serve as a unit test. I think the only signal that the Py_Finalize is invoked is that the module dictionary is cleared and an object with a destructor could be put into it to get a callback. Alternately the c log function could somehow check to see if it can call python functions.
I think the second alternative is way simpler. Call Py_IsInitialized() in the log handler, and if it returns false delegate to the default glib log handler.
Fixed using method in comment 2.