GNOME Bugzilla – Bug 311570
Python bindings segfault in when changing color
Last modified: 2005-07-26 14:44:43 UTC
Hi, Ethan Glasser-Camp reported in Debian bug http://bugs.debian.org/319987 that the python bindings are segfaulting when running this script: import gtk import vte w = gtk.Window() v = vte.Terminal() w.add(v) v.show() w.show() black = gtk.gdk.Color(0, 0, 0) white = gtk.gdk.Color(255, 255, 255) palette = [gtk.gdk.Color(255,255,255) for x in range(8)] v.set_colors(black, white, palette) gtk.main() He explains: " I tracked the problem down to the python/vte.c file, in _wrap_vte_terminal_set_colors(), line 472 or so: if (PySequence_Check(py_palette)) { palette_size = PySequence_Length(py_palette); palette = g_malloc(sizeof(GdkColor) * palette_size); for (i = 0; i < palette_size; i++) { item = PySequence_GetItem(py_palette, i); /* INCREFs */ if (!pyg_boxed_check(item, GDK_TYPE_COLOR)) { g_free(palette); PyErr_SetString(PyExc_TypeError, "palette should be a list of GdkColors"); return NULL; } /* Good here */ palette[i] = *((GdkColor*)pyg_boxed_get(py_palette, GdkColor)); /* Never get here -- ^^^^^ segfaults!! */ printf("about to dec\n"); Py_DECREF(item); printf("decremented successfully\n"); } } I think py_palette in this line should be changed to item. I haven't done any strenuous testing, but this appears to make the program not seg fault. " Bye, PS: Python category for bugs?
Hi Loïc, thanks a lot for this report. Yes that is the correct fix, it only has to be applied to python/vte.override since python/vte.c is a generated file. I'll attach the patch, here's the relevant ChangeLog : +2005-07-26 Michele Baldessari <michele@pupazzo.org> + + * python/vte.override (_wrap_vte_terminal_set_colors): + pyg_boxed_get should be on item not py_palette. + Reported with fix by Loïc Minier <lool+gnome@via.ecp.fr> + Closes bug #311570 +
Created attachment 49781 [details] [review] Fixes the segfault
Commited. Thanks.