You may skip my ramblings to find the actual fix, to imlib, in the bottom. I'm just including some of the stuff I wrote for completeness sake, and since I spent many hours debugging before finding the actual problem.
I compiled nethack with DEB_BUILD_OPTIONS="nostrip noopt" dpkg-buildpackage -rfakeroot. Since I consistently got into problems running nethack-gnome with gdb several times in a row I put together this Bad script to be able to do multiple gdb runs after code changes: ---cut--- #!/bin/sh rm -rf /var/games/nethack/ # clean up locks etc. dpkg -i nethack-common*.deb nethack-gnome*.deb chmod -R ugo+w /var/games/nethack/ # nethack-gnome complains about permissions when run under gdb without this sed 's/exec/gdb/' < /usr/lib/games/nethack/nethack-gnome.sh > /tmp/tmp.sh chmod +x /tmp/tmp.sh mv /tmp/tmp.sh /usr/lib/games/nethack/nethack-gnome.sh ---cut--- Using breakpoint at _XError I got either: #0 _XError (dpy=0x8b2e00, rep=0x7fffbed3ff80) at ../../src/XlibInt.c:2855 #1 0x00002b0deda20dbb in _XReply (dpy=0x8b2e00, rep=0x7fffbed3ff80, extra=0, discard=1) at ../../src/XlibInt.c:1817 #2 0x00002b0deda18a09 in XSync (dpy=0x8b2e00, discard=0) at ../../src/Sync.c:48 #3 0x00002b0dec6e165f in gdk_imlib_render () from /usr/lib/libgdk_imlib.so.2 #4 0x00000000005ca3a1 in ghack_image_from_glyph (glyph=2347, force=0) at ../win/gnome/gnglyph.c:220 #5 0x00000000005c951d in gnome_print_glyph (wid=3, x=25, y=11, glyph=2347) at ../win/gnome/gnbind.c:867 #6 0x0000000000455fd1 in flush_screen (cursor_on_u=1) at display.c:1360 #7 0x0000000000421ba2 in newgame () at allmain.c:531 #8 0x00000000005bdeaa in main (argc=1, argv=0x7fffbed40388) at ../sys/unix/unixmain.c:286 or a bit different trace with ghack_menu_window_display as the last interesting function before gdk_imlib_render. In the former case, the glyph seemed to be always 2347. I tried to continue with various parts of the code commented out or changed, but the crash always just moved elsewhere. Eg. if I changed the line 218 in win/gnome/gnglyph.c from: if (ghack_tiles[tile] && (!ghack_tiles[tile]->pixmap || force)) to: if (ghack_tiles[tile] && (!ghack_tiles[tile]->pixmap || force) && glyph != 2347) I always got to the latter trace, bypassing the glyph problem. But the common factor was that no matter what is skipped, gdk_imlib_render is at the top of the list. I also recompiled imlib and gnome libs with nostrip, but the longer backtraces didn't give any additional interesting information I did then some more googling, and found some hints related to color depths. So I tried running X with 8 bit color depth -> voila! Nethack-gnome works now. --- the problem itself --- Finally, I found out that imlib doesn't handle 32-bit visuals properly, so 24-bit should be fine. So a workaround is this: export XLIB_SKIP_ARGB_VISUALS=1 nethack-gnome And the true fix is to add a max24bpp.patch, attached, to imlib sources. It's from https://bugs.launchpad.net/ubuntu/+source/imlib/+bug/70367, but rediffed against the 1.19.15-5 in Debian. It applies cleanly and fixes the problem for me even without the workaround mentioned.
--- gdk_imlib/misc.c.orig 2008-01-03 17:32:02.000000000 +0200 +++ gdk_imlib/misc.c 2008-01-03 17:32:26.000000000 +0200 @@ -455,6 +455,8 @@ if (xvir[i].depth > max) max = xvir[i].depth; } + if (max > 24) + max = 24; if (max > 8) { id->x.depth = max; @@ -1005,6 +1007,8 @@ if (xvir[i].depth > max) max = xvir[i].depth; } + if (max > 24) + max = 24; if (max > 8) { id->x.depth = max; --- Imlib/misc.c.orig 2008-01-03 17:32:02.000000000 +0200 +++ Imlib/misc.c 2008-01-03 17:32:26.000000000 +0200 @@ -423,6 +423,8 @@ if (xvir[i].depth > max) max = xvir[i].depth; } + if (max > 24) + max = 24; if (max > 8) { id->x.depth = max; @@ -1027,6 +1029,8 @@ if (xvir[i].depth > max) max = xvir[i].depth; } + if (max > 24) + max = 24; if (max > 8) { id->x.depth = max;