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 102222 - gdk_pixbuf_new_from_xpm_data() crashes
gdk_pixbuf_new_from_xpm_data() crashes
Status: RESOLVED FIXED
Product: gdk-pixbuf
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 103774 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2002-12-30 15:44 UTC by Pierre Sarrazin
Modified: 2010-07-10 04:04 UTC
See Also:
GNOME target: ---
GNOME version: 2.0



Description Pierre Sarrazin 2002-12-30 15:44:00 UTC
This C program crashes on my system:

----------------------------------------------------
#include <gdk-pixbuf/gdk-pixbuf.h>

/* XPM */
static const char * close_xpm[] = {
"12 12 2 1",
" 	c None",
"+	c #000000",
"            ",
"  +    ++   ",
"  ++  ++++  ",
"   ++ +++   ",
"   +++++    ",
"    +++     ",
"    ++++    ",
"   ++++++   ",
"   ++ ++++  ",
"  ++   ++++ ",
"  +     ++  ",
"            "};

int
main()
{
    (void) gdk_pixbuf_new_from_xpm_data(close_xpm);
    return 0;
}
----------------------------------------------------

I compile it this way with gcc 2.96-112.7.2:

    gcc -g -Wall gdk_pixbuf_new_from_xpm_data.c \
		`pkg-config --cflags --libs gtk+-2.0`

The compiler displays no warnings.  The pkg-config command writes this:

    -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include
    -I/usr/include/atk-1.0 -I/usr/include/pango-1.0
    -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/glib-2.0
    -I/usr/lib/glib-2.0/include  -Wl,--export-dynamic -lgtk-x11-2.0
    -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0
    -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0

Running the a.out executable displays this:

    (process:12732): GdkPixbuf-WARNING **: Can not open pixbuf loader
    module file '/etc/gtk-2.0/gdk-pixbuf.loaders': No such file or
    directory
    Segmentation fault (core dumped)

The only file in /etc/gtk-2.0 is gtk.immodules and it only contains
lines that start with '#'.

The call stack reported by GDB (5.2) after the SIGSEGV is this:

    #0  0x402c883a in gdk_pixbuf_new_from_xpm_data ()
       from /usr/lib/libgdk_pixbuf-2.0.so.0
    #1  0x08048713 in main () at gdk_pixbuf_new_from_xpm_data.c:24
    #2  0x40407336 in __libc_start_main (main=0x8048700 <main>, argc=1, 
	ubp_av=0xbffff5b4, init=0x804857c <_init>, fini=0x8048760 <_fini>, 
	rtld_fini=0x4000d2fc <_dl_fini>, stack_end=0xbffff5ac)
	at ../sysdeps/generic/libc-start.c:129

When the XPM lines (including the /* XPM */ comment) are written
to a file called close.xpm, Electric Eyes 0.3.12 has no problem
displaying it.  Another program of mine, written for GNOME 1.4,
had no problem loading that XPM either.

Here is the output of 'ldd a.out':

    libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0 (0x40029000)
    libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0x40248000)
    libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0 (0x402ad000)
    libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0x402c3000)
    libm.so.6 => /lib/libm.so.6 (0x402d5000)
    libpangoxft-1.0.so.0 => /usr/lib/libpangoxft-1.0.so.0 (0x402f8000)
    libpangox-1.0.so.0 => /usr/lib/libpangox-1.0.so.0 (0x40316000)
    libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0x40322000)
    libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x40352000)
    libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0x40380000)
    libdl.so.2 => /lib/libdl.so.2 (0x40384000)
    libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x40389000)
    libc.so.6 => /lib/libc.so.6 (0x403eb000)
    libXft.so.1 => /usr/X11R6/lib/libXft.so.1 (0x40521000)
    libXrender.so.1 => /usr/X11R6/lib/libXrender.so.1 (0x4054b000)
    libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40550000)
    libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4055e000)
    libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x40655000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

The RPM packages that provide these libraries are the following:

    atk-1.2.0-1
    freetype-2.0.9-2
    glib2-2.2.0-1
    glibc-2.2.4-31
    gtk2-2.2.0-1
    pango-1.0.3.0.200206200240-0.snap.ximian.1
    XFree86-libs-4.1.0-25

Here is the end of the output of 'strace a.out':

    open("/etc/gtk-2.0/gdk-pixbuf.loaders", O_RDONLY|O_LARGEFILE) = -1 ENOENT
	(No such file or directory)
    getpid()                                = 12826
    open("/usr/lib/charset.alias", O_RDONLY|O_LARGEFILE) = -1 ENOENT
	(No such file or directory)
    open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3
    fstat64(3, {st_mode=S_IFREG|0644, st_size=20072, ...}) = 0
    old_mmap(NULL, 20072, PROT_READ, MAP_SHARED, 3, 0) = 0x40017000
    close(3)                                = 0
    brk(0x804d000)                          = 0x804d000
    brk(0x804e000)                          = 0x804e000
    brk(0x804f000)                          = 0x804f000
    getpid()                                = 12826
    brk(0x8057000)                          = 0x8057000
    write(2, "\n(process:12826): GdkPixbuf-WARN"..., 140
    (process:12826): GdkPixbuf-WARNING **: Can not open pixbuf loader
	module file '/etc/gtk-2.0/gdk-pixbuf.loaders':
	No such file or directory
    ) = 140
    --- SIGSEGV (Segmentation fault) ---
    +++ killed by SIGSEGV +++

My system:

    RedHat        7.2
    gcc           2.96-112.7.2
    gdb           5.2-2
    pkgconfig     0.14.0-1.ximian.1

I run GNOME 1.4 with Sawfish 1.0.
Comment 1 Owen Taylor 2002-12-30 16:23:17 UTC
Basically, your GTK+ RPM is broken, though it might be nice
if GTK+ didn't crash in this case. (gdk_pixbuf_new_from_xpm_data()
may need a few more checks)


Comment 2 Owen Taylor 2002-12-30 16:25:38 UTC
(If it isn't clear why your GTK+ RPM is broken, it needs
to create the gtk.immodules and gdk-pixbuf.loaders file
on installation, and they should be both there and
non-empty.

The %post and %postun scripts for the Red Hat RPM look like:


%post
/sbin/ldconfig
umask 022
%{_bindir}/gtk-query-immodules-2.0 > %{_sysconfdir}/gtk-2.0/gtk.immodules
%{_bindir}/gdk-pixbuf-query-loaders >
%{_sysconfdir}/gtk-2.0/gdk-pixbuf.loaders

%postun
/sbin/ldconfig
if [ $1 = 0 ] ; then
        /bin/rm -f %{_sysconfdir}/gtk-2.0/gtk.immodules
        /bin/rm -f %{_sysconfdir}/gtk-2.0/gdk-pixbuf.loaders
fi
)
Comment 3 Pierre Sarrazin 2002-12-30 16:34:27 UTC
I see.  I built the RPM with 'rpm -tb gtk+-2.2.0.tar.gz',
which uses the .spec file stored in the source tarball.

The %post and %postun sections of this .spec file do not
contain the commands mentioned in the previous comment:

  [...]
%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-, root, root)
  [...]
Comment 4 Owen Taylor 2002-12-30 18:42:45 UTC
The spec files aren't maintained ... while creating a spec
file for say, Red Hat 8.0 is feasible, creating a spec
file that will work generically on all RPM based systems
isn't, in my opinion. The GNOME packaging project handled
the spec file maintainence for a while, but it's not
active currently.

I probably should just remove them ... see bug 102231 to
that effect.
Comment 5 Matthias Clasen 2003-01-02 23:14:56 UTC
I fixed the crash in both branches. Closing this bug since the spec
file issue is tracked elsewhere.
Comment 6 Matthias Clasen 2003-01-17 22:30:08 UTC
*** Bug 103774 has been marked as a duplicate of this bug. ***