On Wed, Mar 24, 2021 at 08:12:34PM -0300, Phillip Bushee wrote: > I'm am writing a window manager which uses XpmCreateImageFromData(3) > to read a .xpm file containing the theme of the decoration of the > windows. The program segfaults when calling this function. I use this > function rather than XpmCreatePixmapFromData(3) in order for me to get > a pixel color from the .xpm with XGetPixel(3).
Hi, I've the impression that this is happening because xa->valuemask is being used unitialized in libXpm in the way you're calling it. This seems to fix the crash for me: diff --git shod.c shod.c index 5dcb450..26865d7 100644 --- shod.c +++ shod.c @@ -467,6 +467,7 @@ settheme(void) unsigned int i, j; int status; + memset(&xa, 0, sizeof(xa)); if (config.theme_path) /* if the we have specified a file, read it instead */ status = XpmReadFileToImage(dpy, config.theme_path, &img, NULL, &xa); else /* else use the default theme */ > > This is the code of the window manager: > https://github.com/phillbush/shod/blob/master/shod.c > > This is the .xpm I am reading: > https://github.com/phillbush/shod/blob/master/theme.xpm > > This is what I get running the program under gdb. > > GNU gdb 6.3 > Copyright 2004 Free Software Foundation, Inc. > GDB is free software, covered by the GNU General Public License, and you > are > welcome to change it and/or distribute copies of it under certain > conditions. > Type "show copying" to see the conditions. > There is absolutely no warranty for GDB. Type "show warranty" for > details. > This GDB was configured as "amd64-unknown-openbsd6.8"... > (gdb) run > Starting program: /home/phil/proj/shod/shod > Error while reading shared library symbols: > Dwarf Error: wrong version in compilation unit header (is 4, should be > 2) > [in module /usr/libexec/ld.so] > Error while reading shared library symbols: > Dwarf Error: wrong version in compilation unit header (is 4, should be > 2) > [in module /usr/libexec/ld.so] > Error while reading shared library symbols: > Dwarf Error: wrong version in compilation unit header (is 4, should be > 2) > [in module /usr/libexec/ld.so] > Error while reading shared library symbols: > Dwarf Error: wrong version in compilation unit header (is 4, should be > 2) > [in module /usr/libexec/ld.so] > Error while reading shared library symbols: > Dwarf Error: wrong version in compilation unit header (is 4, should be > 2) > [in module /usr/libexec/ld.so] > > Program received signal SIGSEGV, Segmentation fault. > 0x00007f7fffff2600 in ?? () > (gdb) bt > #0 0x00007f7fffff2600 in ?? () > #1 0x00000960a406b734 in SetColor () from /usr/X11R6/lib/libXpm.so.9.0 > #2 0x00000960a4067ce6 in CreateColors () from > /usr/X11R6/lib/libXpm.so.9.0 > #3 0x00000960a4069916 in xpmParseDataAndCreate () from > /usr/X11R6/lib/libXpm.so.9.0 > #4 0x00000960a4065437 in XpmCreateImageFromData () from > /usr/X11R6/lib/libXpm.so.9.0 > #5 0x0000095e5e85f5db in settheme () at shod.c:473 > #6 0x0000095e5e85bb58 in main () at shod.c:3465 > > I'm running OpenBSD Xenocara. > This is what I get running `X -version`: > > X.Org X Server 1.20.8 > X Protocol Version 11, Revision 0 > Build Operating System: OpenBSD 6.8 amd64 > Current Operating System: OpenBSD thinkbsd.my.domain 6.8 GENERIC.MP#5 > amd64 > Build Date: 24 November 2020 06:57:35AM > > Current version of pixman: 0.38.4 > Before reporting problems, check http://wiki.x.org > to make sure that you have the latest version. > > _______________________________________________ > xorg@lists.x.org: X.Org support > Archives: http://lists.freedesktop.org/archives/xorg > Info: https://lists.x.org/mailman/listinfo/xorg > Your subscription address: %(user_address)s -- Matthieu Herrb _______________________________________________ xorg@lists.x.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: https://lists.x.org/mailman/listinfo/xorg Your subscription address: %(user_address)s