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 311570 - Python bindings segfault in when changing color
Python bindings segfault in when changing color
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
0.11.x
Other Linux
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-07-26 09:56 UTC by Loïc Minier
Modified: 2005-07-26 14:44 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
Fixes the segfault (1.35 KB, patch)
2005-07-26 14:37 UTC, Michele Baldessari
none Details | Review

Description Loïc Minier 2005-07-26 09:56:39 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?
Comment 1 Michele Baldessari 2005-07-26 14:36:50 UTC
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
+
Comment 2 Michele Baldessari 2005-07-26 14:37:23 UTC
Created attachment 49781 [details] [review]
Fixes the segfault
Comment 3 Kjartan Maraas 2005-07-26 14:44:43 UTC
Commited. Thanks.