#20 segfault in gdk_color_alloc()

closed-accepted
None
5
2008-12-26
2008-12-22
Anonymous
No

I am getting a segfault sometimes during startup of gpsim compiled from svn version 2029 on debian etch.

In led.cc line 878, the value of on_color has not yet been initialized which causes an out-of-range indexing error.

I notice that the doc for gdk_color_alloc() indicates that it is deprecated and that gdk_colormap_alloc_color() should be used.

The attached patch fixes the initialization problem by not using on_color (good) and by allocating more colors than required (not good).

This patch also replaces gdk_color_alloc() which is the correct thing to do even though I found that to have no effect.

- Don

Program terminated with signal 11, Segmentation fault.
#0 0xb7795b09 in IA__gdk_colormap_alloc_colors (colormap=0x807f300, colors=0x851ce08, ncolors=1, writeable=0, best_match=1, success=0xbfb7dc84)
at gdkcolor-x11.c:1143
1143 gdkcolor-x11.c: No such file or directory.
in gdkcolor-x11.c
(xxgdb) where
#0 0xb7795b09 in IA__gdk_colormap_alloc_colors (colormap=0x807f300,
colors=0x851ce08, ncolors=1, writeable=0, best_match=1,
success=0xbfb7dc84) at gdkcolor-x11.c:1143
#1 0xb7777b47 in gdk_color_alloc (colormap=0x807f300, color=0x851ce08)
at gdkcolor.c:267
#2 0xb6aae0f8 in Leds::Led::build_window (this=0x83e7238) at led.cc:878
#3 0xb6ab06de in Led (this=0x83e7238, name=0x83e35fc "Coil_C") at
led.cc:896
#4 0xb6ab0817 in Leds::Led::construct (_new_name=0x83e35fc "Coil_C") at
led.cc:944
#5 0xb7e39de3 in ModuleLibrary::InstantiateObject
(sObjectName=@0xbfb7dd90, sInstantiatedName=@0xbfb7dd8c) at
modules.cc:192
#6 0xb7d1bdb4 in cmd_module::module (this=0xb7d50570, cos=0x83e3608,
op1=0x83e3294 "Coil_C") at cmd_module.cc:264
#7 0xb7d1c029 in cmd_module::module (this=0xb7d50570, cos=0x83e3608,
strs=0x83e35b8) at cmd_module.cc:179
#8 0xb7d09d84 in yyparse () at parse.yy:638
#9 0xb7d0c59b in init_parser () at scan.ll:931
#10 0xb7d28ccd in start_parse () at input.cc:458
#11 0xb7d28ecd in parse_string (str=0xbfb7e7f0 "load c
\"netlist.16f877.stc\"\n") at input.cc:470
#12 0x080499ad in main (argc=5, argv=0xbfb7e9a4) at main.cc:368
(xxgdb) up
#1 0xb7777b47 in gdk_color_alloc (colormap=0x807f300, color=0x851ce08)
at gdkcolor.c:267
267 gdkcolor.c: No such file or directory.
in gdkcolor.c
(xxgdb) up
#2 0xb6aae0f8 in Leds::Led::build_window (this=0x83e7238) at led.cc:878
Current language: auto; currently c++
(xxgdb) print on_color
$1 = 105713
(xxgdb)

$ ldd /usr/local/bin/gpsim
linux-gate.so.1 => (0xffffe000)
libgpsim.so.0 => /usr/local/lib/libgpsim.so.0 (0xb7d74000)
libgpsimcli.so.0 => /usr/local/lib/libgpsimcli.so.0 (0xb7d1a000)
libgpsimgui.so.0 => /usr/local/lib/libgpsimgui.so.0 (0xb7c89000)
libgpsim_eXdbm.so.0 => /usr/local/lib/libgpsim_eXdbm.so.0 (0xb7c82000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7b9d000)
libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb7b99000)
libgtkextra-x11-2.0.so.1 => /usr/lib/libgtkextra-x11-2.0.so.1 (0xb7af1000)
libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0 (0xb7807000)
libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0xb7785000)
libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0 (0xb776b000)
libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0xb7755000)
libpangocairo-1.0.so.0 => /usr/lib/libpangocairo-1.0.so.0 (0xb774d000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0xb7722000)
libXext.so.6 => /usr/lib/libXext.so.6 (0xb7714000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0xb770b000)
libXinerama.so.1 => /usr/lib/libXinerama.so.1 (0xb7708000)
libXi.so.6 => /usr/lib/libXi.so.6 (0xb7700000)
libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0xb76fd000)
libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0xb76f4000)
libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0xb76ef000)
libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0xb76b4000)
libcairo.so.2 => /usr/lib/libcairo.so.2 (0xb7652000)
libX11.so.6 => /usr/lib/libX11.so.6 (0xb7566000)
libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0xb752c000)
libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0xb7529000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7525000)
libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0xb7492000)
libreadline.so.5 => /lib/libreadline.so.5 (0xb7462000)
libpopt.so.0 => /lib/libpopt.so.0 (0xb745a000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7435000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb742a000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7418000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb72e6000)
librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb72dd000)
libpangoft2-1.0.so.0 => /usr/lib/libpangoft2-1.0.so.0 (0xb72b2000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0xb7247000)
libz.so.1 => /usr/lib/libz.so.1 (0xb7233000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0xb7213000)
libXau.so.6 => /usr/lib/libXau.so.6 (0xb7210000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0xb71ed000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb71e7000)
/lib/ld-linux.so.2 (0xb7f8e000)
libncurses.so.5 => /usr/lib/libncurses.so.5 (0xb71a6000)

Discussion

  • Nobody/Anonymous

    gdk_color_alloc patch

     
  • Borut Ražem

    Borut Ražem - 2008-12-26

    Patch applied in svn revision #2031.

    Borut

     
  • Borut Ražem

    Borut Ražem - 2008-12-26
    • assigned_to: nobody --> borutr
    • status: open --> closed-accepted
     

Anonymous
Anonymous

Cancel  Add attachments