SDL crashes on LInux ARCH w/Nvidia

I just built from github master, using SDL2 2.0.12 and get:

> gdb ./micropython
Reading symbols from ./micropython...
(gdb) run
Starting program: /home/src/esp32/lvmp/ports/unix/micropython
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
MicroPython v1.9.4-2165-ge795d3765 on 2020-06-20; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import SDL
>>> SDL.init()
[New Thread 0x7ffff45e1700 (LWP 574492)]
>>>
Thread 1 "micropython" received signal SIGSEGV, Segmentation fault.
0x00007ffff5cc9e96 in ?? () from /usr/lib/libnvidia-glcore.so.430.64
(gdb) where
#0  0x00007ffff5cc9e96 in ?? () from /usr/lib/libnvidia-glcore.so.430.64
#1  0x00007ffff5cca4d0 in ?? () from /usr/lib/libnvidia-glcore.so.430.64
#2  0x00007ffff5ca2c3e in ?? () from /usr/lib/libnvidia-glcore.so.430.64
#3  0x00007ffff5cb0867 in ?? () from /usr/lib/libnvidia-glcore.so.430.64
#4  0x00007ffff5cb9c7c in ?? () from /usr/lib/libnvidia-glcore.so.430.64
#5  0x00007ffff7cdb73f in ?? () from /usr/lib/libSDL2-2.0.so.0
#6  0x00007ffff7ccf6e1 in ?? () from /usr/lib/libSDL2-2.0.so.0
#7  0x00007ffff7cd498d in ?? () from /usr/lib/libSDL2-2.0.so.0
#8  0x00005555556c09d4 in monitor_sdl_refr_core ()
    at ../../lib/lv_bindings/driver/SDL/SDL_monitor.c:181
#9  0x00005555556c0cb1 in mp_lv_task_handler (arg=0x555555728fb0 <mp_const_none_obj>)
    at ../../lib/lv_bindings/driver/SDL/modSDL.c:17
#10 0x00005555555da246 in fun_builtin_1_call (self_in=0x555555754a20 <mp_lv_task_handler_obj>,
    n_args=1, n_kw=0, args=0x7fffffffd470) at ../../py/objfun.c:70
#11 0x00005555555ceaf4 in mp_call_function_n_kw (fun_in=0x555555754a20 <mp_lv_task_handler_obj>,
    n_args=1, n_kw=0, args=0x7fffffffd470) at ../../py/runtime.c:642
#12 0x00005555555cea39 in mp_call_function_1 (fun=0x555555754a20 <mp_lv_task_handler_obj>,
    arg=0x555555728fb0 <mp_const_none_obj>) at ../../py/runtime.c:620
#13 0x00005555555d0dc7 in mp_call_function_1_protected (
    fun=0x555555754a20 <mp_lv_task_handler_obj>, arg=0x555555728fb0 <mp_const_none_obj>)
    at ../../py/runtime_utils.c:33
#14 0x00005555555d0fb4 in mp_handle_pending_tail (atomic_state=0) at ../../py/scheduler.c:72
#15 0x00005555555d0f28 in mp_handle_pending () at ../../py/scheduler.c:59
#16 0x000055555560389f in mp_hal_stdin_rx_chr () at unix_mphal.c:177
#17 0x00005555556c1a0a in readline (line=0x7fffffffd5d0, prompt=0x5555556d3feb ">>> ")
    at ../../lib/mp-readline/readline.c:425
#18 0x00005555556022cf in do_repl () at main.c:198
#19 0x000055555560333b in main_ (argc=1, argv=0x7fffffffd878) at main.c:651
#20 0x00005555556028d2 in main (argc=1, argv=0x7fffffffd878) at main.c:425

I see the TFT Simulator window being created and after a half-second pause the crash occurs. Any suggestions?

It’s a known bug with Nvidia cards: https://github.com/lvgl/lv_binding_micropython/issues/46

The crash happens inside an Nvidia driver somewhere, meaning that we don’t really know why this happens. The current workaround is to use Intel graphics instead (if you have them).

Are you using Ubuntu 18.04 by chance?

Thanks for the link to the bug. I’m using an Arch linux derivative (Manjaro). Can’t switch to another graphics card 'cause there’s no other.
Is there a way to disable hardware acceleration or make it fall back to some generic driver?

Not sure. I’ll see if I can make it work, as I can now reproduce the same issue (I switched to an Nvidia card a few months after that issue was reported).

1 Like

It insists on using libnvidia no matter how many software-only APIs I try! The weirdest part is that the standard C-based PC simulator works without problems. I’ll have to compare the SDL-related code and see what’s been changed.

1 Like

If you don’t mind, since this is the same issue as https://github.com/lvgl/lv_binding_micropython/issues/46, let’s continue the discussion over there so we have it in one place.

Looks like on Ubuntu 22.04 with nvidia-driver-510 on my GeForce GTX 950M this problem has disappeared