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 334188 - Segfault when using g_log after Py_Finalize is called
Segfault when using g_log after Py_Finalize is called
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal critical
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2006-03-11 04:11 UTC by James "Doc" Livingston
Modified: 2006-04-01 18:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description James "Doc" Livingston 2006-03-11 04:11:59 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:

  • #0 PyErr_Fetch
    at ../Python/errors.c line 210
  • #1 PyModule_GetWarningsModule
    at ../Python/pythonrun.c line 88
  • #2 PyErr_Warn
    at ../Python/errors.c line 603
  • #3 ??
    from /usr/lib/python2.4/site-packages/gtk-2.0/gobject.so
  • #4 ??
  • #5 ??
  • #6 ??
  • #7 g_log_domain_get_handler_L
    at gmessages.c line 225
  • #8 IA__g_logv
    at gmessages.c line 474
  • #9 IA__g_log
    at gmessages.c line 517
  • #10 IA__g_return_if_fail_warning
    at gmessages.c line 532


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.
Comment 1 John Ehresman 2006-03-11 04:32:18 UTC
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.
Comment 2 Gustavo Carneiro 2006-03-11 11:31:25 UTC
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.
Comment 3 Gustavo Carneiro 2006-04-01 18:20:28 UTC
Fixed using method in comment 2.