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 442747 - crashers in python bindings
crashers in python bindings
Status: RESOLVED FIXED
Product: gnome-menus
Classification: Core
Component: general
unspecified
Other Windows
: Normal normal
: ---
Assigned To: gnome-menus dummy account
gnome-menus dummy account
Depends on:
Blocks:
 
 
Reported: 2007-06-01 01:14 UTC by Colin Walters
Modified: 2007-06-14 19:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix 3 crashers (892 bytes, patch)
2007-06-01 01:15 UTC, Colin Walters
accepted-commit_now Details | Review
fixes for python binding crashers (947 bytes, patch)
2007-06-06 00:08 UTC, Colin Walters
committed Details | Review

Description Colin Walters 2007-06-01 01:14:27 UTC
Hi, attached patch should fix 3 potential crashers in the Python bindings.

1) If you pass a non-callable to add_monitor, it would happily invoke it.  This is fixed by adding PyCallable_Check.
2) If you pass a lambda it would still segfault, because it was using PyObject_CallObject instead of the more general PyEval_CallObject.
3) If the user data was omitted, the python field would be junk.  Fixed by setting it to null.
Comment 1 Colin Walters 2007-06-01 01:15:24 UTC
Created attachment 89142 [details] [review]
fix 3 crashers
Comment 2 Vincent Untz 2007-06-01 14:22:01 UTC
Thanks. Can you commit after changing the coding style to match what's used in gmenu.c?

That is:

+  if (!PyCallable_Check (pycallback))
+    {
+      PyErr_SetString (PyExc_TypeError, "parameter must be callable");
+      return NULL;
+    }
Comment 3 Colin Walters 2007-06-06 00:08:02 UTC
Ok, turned out the real crasher was not what I thought - instead it was that gnome-menus needed to acquire the global Python lock when invoking callbacks.

This new patch seems to be a reliable fix.  I'll commit it later if no one objects.
Comment 4 Colin Walters 2007-06-06 00:08:46 UTC
Created attachment 89445 [details] [review]
fixes for python binding crashers
Comment 5 Vincent Untz 2007-06-06 08:00:09 UTC
It looks like most python bindings are using pyg_gil_state_ensure() and pyg_gil_state_release() from pygobject.
Comment 6 Colin Walters 2007-06-06 18:05:47 UTC
Right, those are the PyGTK wrappers around the core Python functions which they use for compatibility with older versions of Python (2.2 and below).  But right now gnome-menus doesn't depend on pygobject.  Python 2.3 was released just about 4 years ago now, it seems reasonable to me to depend on it.  What do you think?


Comment 7 Vincent Untz 2007-06-06 20:00:00 UTC
I know nothing about python bindings: I'm just looking at other bindings to see what they're doing :-)

If you're confident about this, just go ahead. Or you can ask Mark.
Comment 8 Colin Walters 2007-06-14 19:06:56 UTC
Committed.