Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash under SDL_RenderPresent, only in XMonad #513

Closed
SandTAS opened this issue Dec 18, 2022 · 1 comment
Closed

Crash under SDL_RenderPresent, only in XMonad #513

SandTAS opened this issue Dec 18, 2022 · 1 comment

Comments

@SandTAS
Copy link

SandTAS commented Dec 18, 2022

I get a crash (segmentation fault or assertion failure) with certain programs. I first encountered it trying to run pcem, but I can also reproduce it with utils/simplestgame. The strange thing is, the crash only happens when I am using the XMonad window manager. With XFCE or another desktop environment, pcem and the other programs work.

In the cases I have seen, the function SDL_RenderPresent is present in the stack trace; however I don't know if that function is the immediate cause.

Below are instructions to reproduce the segmentation fault using a Debian live CD. You can download an image from https://www.debian.org/CD/live/ and run it in a VM (e.g. kvm -m 3G -cdrom debian-live-11.6.0-amd64-xfce.iso). First, we'll run libTAS under XFCE and see that it works; then we'll install XMonad and see the crash.

  1. Open a terminal and install libTAS 1.4.4.
    sudo apt update
    curl -L -O https://github.com/clementgallet/libTAS/releases/download/v1.4.4/libtas_1.4.4_amd64.deb
    sudo apt install ./libtas_1.4.4_amd64.deb
    
  2. Compile simplestgame.
    curl -L -O https://github.com/clementgallet/libTAS/archive/refs/tags/v1.4.4.tar.gz
    tar xf v1.4.4.tar.gz
    sudo apt install libsdl2-dev
    (cd libTAS-1.4.4/utils && gcc -o simplestgame $(pkg-config --cflags sdl2) simplestgame.c $(pkg-config --libs sdl2))
    
  3. Run simplestgame in libTAS.
    libTAS ~/libTAS-1.4.4/utils/simplestgame
    
    Click Start, uncheck Pause, and let it run for about 10 seconds. It should run without crashing. Click Stop and close libTAS.
  4. Install XMonad.
    sudo apt install xmonad
    
  5. Log out and log back in with XMonad. The desktop environment selector is in the upper right, next to the 🚹 icon.
    Username: user
    Password: live
  6. Type Shift+Alt+Enter to open a terminal. (Use Shift+Alt+/ to get a list of other keyboard commands.)
  7. Run simplestgame in libTAS.
    libTAS ~/libTAS-1.4.4/utils/simplestgame
    
    Click Start, uncheck Pause, and let it run for about 10 seconds. For me, it crashes with this message in the console:
    simplestgame: malloc.c:2379: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
    Aborted
    recv() returns -1 with error Connection reset by peer
    The connection to the game was lost. Exiting
    
  8. To exit XMonad, type Shift+Alt+q.

When I Launch with GDB, this is the stack track in simplestgame I see after the crash:

Starting program: /home/user/libTAS-1.4.4/utils/simplestgame
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Attempt 1: Couldn't connect to socket.
Attempt 2: Connected.
[New Thread 0x7fffed7b7700 (LWP 104815)]
[New Thread 0x7fffe4fb6700 (LWP 104816)]
[New Thread 0x7fffecfb6700 (LWP 104817)]
[New Thread 0x7fffe7fff700 (LWP 104818)]
[New Thread 0x7fffe77fe700 (LWP 104819)]
[New Thread 0x7fffe6ffd700 (LWP 104820)]
[New Thread 0x7fffe67fc700 (LWP 104821)]
[New Thread 0x7fffe5ffb700 (LWP 104822)]
[New Thread 0x7fffe57fa700 (LWP 104823)]
[New Thread 0x7fffc7fff700 (LWP 104824)]
[New Thread 0x7fffc77fe700 (LWP 104825)]
[New Thread 0x7fffc6ffd700 (LWP 104826)]
[libTAS f:0] Thread 104811 (main) OpenGL vendor: Mesa/X.org
[libTAS f:0] Thread 104811 (main) OpenGL renderer: llvmpipe (LLVM 11.0.1, 256 bits)
simplestgame: malloc.c:2379: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.

Thread 1 "simplestgame" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7948537 in __GI_abort () at abort.c:79
#2  0x00007ffff79a8a38 in __malloc_assert (
    assertion=assertion@entry=0x7ffff7ac19c8 "(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)", file=file@entry=0x7ffff7abcf88 "malloc.c", line=line@entry=2379,
    function=function@entry=0x7ffff7ac2150 <__PRETTY_FUNCTION__.3> "sysmalloc") at malloc.c:298
#3  0x00007ffff79aaa4a in sysmalloc (nb=nb@entry=2832, av=av@entry=0x7ffff7af5b80 <main_arena>) at malloc.c:2379
#4  0x00007ffff79ac1b5 in _int_malloc (av=av@entry=0x7ffff7af5b80 <main_arena>, bytes=bytes@entry=2824) at malloc.c:4141
#5  0x00007ffff79aded1 in __libc_calloc (n=<optimized out>, elem_size=<optimized out>) at malloc.c:3428
#6  0x00007ffff7b85314 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#7  0x00007ffff7b2dc58 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#8  0x00007ffff7bbed73 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#9  0x00007ffff7b81b46 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#10 0x00007ffff7b59bdc in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#11 0x00007ffff7d15b5a in ?? () from /usr/bin/libtas.so
#12 0x00007ffff7d186ef in ?? () from /usr/bin/libtas.so
#13 0x00007ffff7d17cc9 in ?? () from /usr/bin/libtas.so
#14 0x00007ffff7d17de2 in ?? () from /usr/bin/libtas.so
#15 0x00007ffff7cca69f in ?? () from /usr/bin/libtas.so
#16 0x00007ffff7d236f7 in SDL_RenderPresent () from /usr/bin/libtas.so
#17 0x0000555555555302 in main ()

This is the stack trace of pcem:

Starting program: /usr/bin/pcem
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Attempt 2: Couldn't connect to socket.
Attempt 3: Connected.
Set fullspeed - 0 0 0
[New Thread 0x7fffe09e2700 (LWP 96785)]
[New Thread 0x7fffd81e1700 (LWP 96786)]
[New Thread 0x7fffdbfff700 (LWP 96787)]
[New Thread 0x7fffdb7fe700 (LWP 96788)]
[New Thread 0x7fffdaffd700 (LWP 96789)]
[New Thread 0x7fffda7fc700 (LWP 96790)]
[New Thread 0x7fffd9ffb700 (LWP 96791)]
[New Thread 0x7fffd97fa700 (LWP 96792)]
[New Thread 0x7fffd8ff9700 (LWP 96793)]
[New Thread 0x7fffd79e0700 (LWP 96794)]
[New Thread 0x7fffd71df700 (LWP 96795)]
[New Thread 0x7fffd69de700 (LWP 96796)]
[libTAS f:0] Thread 96780 (main) OpenGL vendor: Mesa/X.org
[libTAS f:0] Thread 96780 (main) OpenGL renderer: llvmpipe (LLVM 11.0.1, 256 bits)
[New Thread 0x7fffd51dc700 (LWP 96797)]
[New Thread 0x7fffd49db700 (LWP 96798)]
Menu item not found: 1403
Menu item not found: 1404
Load ROM image /home/user/.pcem/roms/mda.rom
Load ROM image /home/user/.pcem/roms/wy700.rom
Load ROM image /home/user/.pcem/roms/8x12.bin
Load ROM image /home/user/.pcem/roms/tandy1000sl2/8079047.hu1
Load ROM image /home/user/.pcem/roms/tandy1000sl2/8079048.hu2
Load ROM image /home/user/.pcem/roms/mda.rom
Load ROM image /home/user/.pcem/roms/wy700.rom
Load ROM image /home/user/.pcem/roms/8x12.bin
Load ROM image /home/user/.pcem/roms/tandy1000sl2/8079047.hu1
Load ROM image /home/user/.pcem/roms/tandy1000sl2/8079048.hu2
Load ROM image /home/user/.pcem/roms/tandy1000sl2/8079047.hu1
Load ROM image /home/user/.pcem/roms/tandy1000sl2/8079048.hu2
ALSA lib rawmidi_hw.c:235:(snd_rawmidi_hw_open) open /dev/snd/midiC0D0 failed: No such file or directory
[New Thread 0x7fff9ffff700 (LWP 96799)]
[libTAS f:0] Thread 96799  Switching main thread from -208930048 to -1610615040
[New Thread 0x7fff9f7fe700 (LWP 96800)]
Menu item not found: 1403
Menu item not found: 1404

Thread 16 "SDL2 Thread" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff9ffff700 (LWP 96799)]
__memmove_sse2_unaligned_erms ()
    at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:295
295     ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) bt
#0  __memmove_sse2_unaligned_erms ()
    at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:295
#1  0x00007ffff6edaea9 in  () at /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#2  0x00007ffff6e9be18 in  () at /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#3  0x00007ffff6e78ebe in  () at /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#4  0x00007ffff7cd6094 in  () at /usr/bin/libtas.so
#5  0x00007ffff7ccb2b2 in  () at /usr/bin/libtas.so
#6  0x00007ffff7d236f7 in SDL_RenderPresent () at /usr/bin/libtas.so
#7  0x0000555555a9d9bc in  ()
#8  0x0000555555a8ab7e in  ()
#9  0x0000555555ad3f8c in  ()
#10 0x0000555555ad528d in  ()
#11 0x00007ffff6ea06df in  () at /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#12 0x00007ffff6f27349 in  () at /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#13 0x00007ffff7cd2ef0 in  () at /usr/bin/libtas.so
#14 0x00007ffff7afcea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#15 0x00007ffff6a0fa2f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
@clementgallet
Copy link
Owner

I fixed the pcem issue but didn't check the other one, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants