libtcod/python-tcod

tcod.image_from_console segfaults

Ape opened this issue · 3 comments

Ape commented

I tried to use tcod.image_from_console to take screenshots, but it just segfaults. I am using python-tcod 10.0.5 on Arch Linux and the SDL2 renderer.

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
#0  0x00007ffff70d6180 in _Z26TCOD_sys_console_to_bitmapP11SDL_SurfaceP12TCOD_ConsoleS2_ (
    vbitmap=0x555556e82ae0, console=0x5555565837d0, cache=0x0)
    at libtcod/src/libtcod/sys_sdl_c.cpp:567
#1  0x00007ffff70e5c54 in TCOD_image_from_console (console=0x0)
    at libtcod/src/libtcod/image_c.cpp:445
#2  0x00007ffff7136d8f in _cffi_f_TCOD_image_from_console (self=<optimized out>, 
    arg0=0x7ffff72e08f0) at build/temp.linux-x86_64-3.7/tcod._libtcod.c:38699
#3  0x00007ffff7b83db8 in _PyMethodDef_RawFastCallKeywords ()
   from /usr/lib/libpython3.7m.so.1.0
#4  0x00007ffff7b84101 in _PyCFunction_FastCallKeywords () from /usr/lib/libpython3.7m.so.1.0
#5  0x00007ffff7bf4d19 in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.7m.so.1.0
#6  0x00007ffff7b3ddbb in _PyFunction_FastCallDict () from /usr/lib/libpython3.7m.so.1.0
#7  0x00007ffff7bf183e in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.7m.so.1.0
#8  0x00007ffff7b3cd09 in _PyEval_EvalCodeWithName () from /usr/lib/libpython3.7m.so.1.0
#9  0x00007ffff7b83882 in _PyFunction_FastCallKeywords () from /usr/lib/libpython3.7m.so.1.0
#10 0x00007ffff7bf46ea in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.7m.so.1.0
#11 0x00007ffff7b836db in _PyFunction_FastCallKeywords () from /usr/lib/libpython3.7m.so.1.0
#12 0x00007ffff7bf022d in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.7m.so.1.0
#13 0x00007ffff7b3cd09 in _PyEval_EvalCodeWithName () from /usr/lib/libpython3.7m.so.1.0
#14 0x00007ffff7b3dc64 in PyEval_EvalCodeEx () from /usr/lib/libpython3.7m.so.1.0
#15 0x00007ffff7b3dc8c in PyEval_EvalCode () from /usr/lib/libpython3.7m.so.1.0
#16 0x00007ffff7c06a0d in ?? () from /usr/lib/libpython3.7m.so.1.0
#17 0x00007ffff7b83ef3 in _PyMethodDef_RawFastCallKeywords ()
   from /usr/lib/libpython3.7m.so.1.0
#18 0x00007ffff7b84101 in _PyCFunction_FastCallKeywords () from /usr/lib/libpython3.7m.so.1.0
#19 0x00007ffff7bf4552 in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.7m.so.1.0
#20 0x00007ffff7b3cd09 in _PyEval_EvalCodeWithName () from /usr/lib/libpython3.7m.so.1.0
#21 0x00007ffff7b83882 in _PyFunction_FastCallKeywords () from /usr/lib/libpython3.7m.so.1.0
#22 0x00007ffff7bf022d in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.7m.so.1.0
#23 0x00007ffff7b3cd09 in _PyEval_EvalCodeWithName () from /usr/lib/libpython3.7m.so.1.0
#24 0x00007ffff7b3df8c in _PyFunction_FastCallDict () from /usr/lib/libpython3.7m.so.1.0
#25 0x00007ffff7c6bdd7 in ?? () from /usr/lib/libpython3.7m.so.1.0
#26 0x00007ffff7c6d172 in ?? () from /usr/lib/libpython3.7m.so.1.0
#27 0x00007ffff7c6d4ec in _Py_UnixMain () from /usr/lib/libpython3.7m.so.1.0
#28 0x00007ffff7dcace3 in __libc_start_main () from /usr/lib/libc.so.6
#29 0x000055555555505e in _start ()

(gdb) info locals
charmap_backup = 0x0
bitmap = 0x555556e82ae0
sdl_back = 0
sdl_fore = 0
fading_color = {r = 0 '\000', g = 0 '\000', b = 0 '\000'}
fade = 255
track_changes = false
bpp = <optimized out>
hdelta = <optimized out>

(gdb) info args
vbitmap = 0x555556e82ae0
console = 0x5555565837d0
cache = 0x0
Ape commented

I guess the interesting bit in that backtrace is:

1 in TCOD_image_from_console (console=0x0)

Also the global SDL_Surface* charmap in sys_sdl_c.cpp is null when the crash happens.

This is one of the functions not converted to the newer rendering yet. The old renderer doesn't support loading TrueType fonts so it won't have a tileset when invoked.

I'll need to write a new software renderer to fix this.

Ape commented

Good to know. This is not super important function for me, but it could be handy at times.