DisplayLink / evdi

Extensible Virtual Display Interface
MIT License
689 stars 179 forks source link

GPU-less system: application / LLVMpipe crashes with SIGBUS (Bus error) #444

Closed tom-ton closed 6 months ago

tom-ton commented 6 months ago

System: Intel(R) Atom(TM) CPU C3758R @ 2.40GHz (8 cores) GPU: no GPU of any sort present Using Wayland.

Because of missing GPU, software rasterizer LLVMpipe is in use. If running multi-threaded (no LP_NUM_THREADS=1 env var is set), SIGBUS crash is observed.

Example gdm fails to start:

...
Dec 25 19:08:52 cordoba gnome-session[4977]: gnome-session-binary[4977]: WARNING: Application 'org.gnome.Shell.desktop' killed by signal 7
Dec 25 19:08:52 cordoba gnome-session-binary[4977]: WARNING: App 'org.gnome.SettingsDaemon.MediaKeys.desktop' exited with code 1
Dec 25 19:08:52 cordoba gnome-session-binary[4977]: WARNING: App 'org.gnome.SettingsDaemon.Power.desktop' exited with code 1
Dec 25 19:08:52 cordoba gnome-session-binary[4977]: WARNING: Application 'org.gnome.Shell.desktop' killed by signal 7
Dec 25 19:08:52 cordoba polkitd[873]: Unregistered Authentication Agent for unix-session:c2 (system bus name :1.90, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Dec 25 19:08:52 cordoba gnome-session-binary[4977]: Unrecoverable failure in required component org.gnome.Shell.desktop

Example weston fails to start:

Date: 2023-12-25 CET
[19:18:40.828] weston 12.0.1
               https://wayland.freedesktop.org
               Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
               Build: 12.0.1
[19:18:40.828] Command line: weston
[19:18:40.828] OS: Linux, 6.5.0-14-generic, #14-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:59:49 UTC 2023, x86_64
[19:18:40.828] Flight recorder: enabled
[19:18:40.828] warning: XDG_RUNTIME_DIR "/run/user/1000" is not configured
correctly.  Unix access mode must be 0700 (current mode is 0700),
and must be owned by the user UID 0 (current owner is UID 1000).
Refer to your distribution on how to get it, or
http://www.freedesktop.org/wiki/Specifications/basedir-spec
on how to implement it.
[19:18:40.828] Using config file '/home/cordoba/.config/weston.ini'
[19:18:40.828] Output repaint window is 7 ms maximum.
[19:18:40.828] Loading module '/usr/lib/x86_64-linux-gnu/libweston-12/drm-backend.so'
[19:18:40.832] initializing drm backend
[19:18:40.832] Trying libseat launcher...
[19:18:40.832] [libseat/backend/seatd.c:64] Could not connect to socket /run/seatd.sock: No such file or directory
[19:18:40.832] [libseat/libseat.c:76] Backend 'seatd' failed to open seat, skipping
[19:18:40.832] [libseat/libseat.c:76] Backend 'logind' failed to open seat, skipping
[19:18:40.833] [seatd/seat.c:39] Created VT-bound seat seat0
[19:18:40.834] [seatd/server.c:145] New client connected (pid: 15432, uid: 0, gid: 0)
[19:18:40.834] [libseat/backend/seatd.c:633] Started embedded seatd
[19:18:40.834] [seatd/seat.c:170] Added client 1 to seat0
[19:18:40.834] [seatd/seat.c:480] Opened client 1 on seat0
[19:18:40.834] [libseat/libseat.c:73] Seat opened with backend 'builtin'
[19:18:40.834] [libseat/backend/seatd.c:212] Enabling seat
[19:18:40.834] libseat: session control granted
[19:18:40.841] using /dev/dri/card0
[19:18:40.841] DRM: supports atomic modesetting
[19:18:40.841] DRM: supports GBM modifiers
[19:18:40.841] DRM: supports picture aspect ratio
MESA-LOADER: failed to open evdi: /usr/lib/dri/evdi_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
kmsro: driver missing
[19:18:40.897] Loading module '/usr/lib/x86_64-linux-gnu/libweston-12/gl-renderer.so'
[19:18:40.901] warning: failed to query rendering device from EGL
[19:18:40.901] EGL version: 1.5
[19:18:40.901] EGL vendor: Mesa Project
[19:18:40.901] EGL client APIs: OpenGL OpenGL_ES 
[19:18:40.901] warning: Disabling render GPU timeline and explicit synchronization due to missing EGL_ANDROID_native_fence_sync extension
[19:18:40.901] EGL features:
               EGL Wayland extension: no
               context priority: no
               buffer age: yes
               partial update: no
               swap buffers with damage: no
               configless context: yes
               surfaceless context: yes
               dmabuf support: modifiers
[19:18:40.912] GL version: OpenGL ES 3.2 Mesa 23.2.1-1ubuntu3.1
[19:18:40.912] GLSL version: OpenGL ES GLSL ES 3.20
[19:18:40.912] GL vendor: Mesa
[19:18:40.912] GL renderer: llvmpipe (LLVM 15.0.7, 128 bits)
[19:18:40.922] GL ES 3.2 - renderer features:
               read-back format: ARGB8888
               glReadPixels supports y-flip: yes
               wl_shm 10 bpc formats: yes
               wl_shm 16 bpc formats: yes
               wl_shm half-float formats: yes
               internal R and RG formats: yes
               OES_EGL_image_external: yes
[19:18:40.922] Using GL renderer
[19:18:40.931] event1  - Power Button: is tagged by udev as: Keyboard
[19:18:40.931] event1  - Power Button: device is a keyboard
[19:18:40.933] event0  - Power Button: is tagged by udev as: Keyboard
[19:18:40.933] event0  - Power Button: device is a keyboard
[19:18:40.936] event2  - Logitech M215: is tagged by udev as: Keyboard Mouse
[19:18:40.936] event2  - Logitech M215: device is a pointer
[19:18:40.936] event2  - Logitech M215: device is a keyboard
[19:18:40.939] event3  - Logitech K230: is tagged by udev as: Keyboard
[19:18:40.939] event3  - Logitech K230: device is a keyboard
[19:18:40.948] libinput: configuring device "Power Button".
[19:18:40.948] libinput: configuring device "Power Button".
[19:18:40.948] libinput: configuring device "Logitech M215".
[19:18:40.948] libinput: configuring device "Logitech K230".
[19:18:40.949] DRM: head 'DVI-I-1' found, connector 37 is connected, EDID make 'HPN', model 'HP 24fh', serial '3CM0300XC0  '
               Supported EOTF modes: SDR
[19:18:40.949] Registered plugin API 'weston_drm_output_api_v1' of size 40
[19:18:40.949] Registered plugin API 'weston_drm_virtual_output_api_v2' of size 48
[19:18:40.949] Color manager: no-op
[19:18:40.949] Output 'DVI-I-1' attempts EOTF mode: SDR
[19:18:40.949] Output 'DVI-I-1' using color profile: built-in default sRGB SDR profile
[19:18:40.949] Chosen EGL config details: id:  31 rgba: 8 8 8 0 buf: 24 dep:  0 stcl: 0 int: 1-1 type: win vis_id: XRGB8888 (0x34325258)
[19:18:40.949] Output DVI-I-1 (crtc 35) video modes:
               1920x1080@60.0, preferred, current, 148.5 MHz
               1920x1080@60.0 16:9, 148.5 MHz
               1920x1080@59.9 16:9, 148.4 MHz
               1920x1080@50.0 16:9, 148.5 MHz
               1680x1050@59.9, 119.0 MHz
               1600x900@60.0, 108.0 MHz
               1280x1024@60.0, 108.0 MHz
               1440x900@59.9, 88.8 MHz
               1280x800@59.9, 71.0 MHz
               1280x720@60.0, 74.2 MHz
               1280x720@60.0 16:9, 74.2 MHz
               1280x720@59.9 16:9, 74.2 MHz
               1280x720@50.0, 74.2 MHz
               1280x720@50.0 16:9, 74.2 MHz
               1024x768@60.0, 65.0 MHz
               800x600@60.3, 40.0 MHz
               720x576@50.0 16:9, 27.0 MHz
               720x576@50.0 4:3, 27.0 MHz
               720x480@60.0 4:3, 27.0 MHz
               720x480@60.0 16:9, 27.0 MHz
               720x480@59.9, 27.0 MHz
               720x480@59.9 16:9, 27.0 MHz
               720x480@59.9 4:3, 27.0 MHz
               640x480@60.0 4:3, 25.2 MHz
               640x480@59.9, 25.2 MHz
               640x480@59.9 4:3, 25.2 MHz
               720x400@70.1, 28.3 MHz
[19:18:40.950] associating input device event1 with output DVI-I-1 (none by udev)
[19:18:40.950] associating input device event0 with output DVI-I-1 (none by udev)
[19:18:40.950] associating input device event2 with output DVI-I-1 (none by udev)
[19:18:40.950] associating input device event3 with output DVI-I-1 (none by udev)
[19:18:40.950] Output 'DVI-I-1' enabled with head(s) DVI-I-1
[19:18:40.950] Compositor capabilities:
               arbitrary surface rotation: yes
               screen capture uses y-flip: yes
               cursor planes: yes
               arbitrary resolutions: no
               view mask clipping: yes
               explicit sync: no
               color operations: yes
               presentation clock: CLOCK_MONOTONIC, id 1
               presentation clock resolution: 0.000000001 s
[19:18:40.950] Loading module '/usr/lib/x86_64-linux-gnu/weston/desktop-shell.so'
[19:18:40.950] Loading module '/usr/lib/x86_64-linux-gnu/libweston-12/xwayland.so'
[19:18:40.958] Registered plugin API 'weston_xwayland_v1' of size 32
[19:18:40.958] Registered plugin API 'weston_xwayland_surface_v1' of size 16
[19:18:40.958] unlinking stale lock file /tmp/.X0-lock
[19:18:40.959] xserver listening on display :0
[19:18:40.959] launching '/usr/lib/x86_64-linux-gnu/weston-keyboard'
[19:18:40.962] launching '/usr/lib/x86_64-linux-gnu/weston-desktop-shell'
Failed to process Wayland connection: Connection reset by peer
Failed to process Wayland connection: Connection reset by peer
failed to create display: Connection reset by peer
failed to create display: Connection reset by peer
[19:18:41.248] [seatd/client.c:471] Client disconnected
Bus error

Start weston in gdb with LP_NUM_THREADS=2:

...
Thread 3 "llvmpipe-1" received signal SIGBUS, Bus error.
[Switching to Thread 0x7ffff63aa6c0 (LWP 15510)]
0x00007ffff7f8e65b in ?? ()
(gdb) i threads 
  Id   Target Id                                         Frame 
  1    Thread 0x7ffff7788900 (LWP 15505) "weston"        0x00007ffff7c94076 in __futex_abstimed_wait_common64 (
    private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x55555612fce8) at ./nptl/futex-internal.c:57
  2    Thread 0x7ffff6bab6c0 (LWP 15509) "llvmpipe-0"    0x00007ffff7f8e549 in ?? ()
* 3    Thread 0x7ffff63aa6c0 (LWP 15510) "llvmpipe-1"    0x00007ffff7f8e65b in ?? ()
  4    Thread 0x7ffff5ba96c0 (LWP 15511) "weston"        0x00007ffff7c94076 in __futex_abstimed_wait_common64 (
    private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x55555561d5c0) at ./nptl/futex-internal.c:57
  5    Thread 0x7fffe91ff6c0 (LWP 15512) "weston"        0x00007ffff7c94076 in __futex_abstimed_wait_common64 (
    private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x55555561d5c0) at ./nptl/futex-internal.c:57
  6    Thread 0x7fffe89fe6c0 (LWP 15513) "weston:disk$0" 0x00007ffff7c94076 in __futex_abstimed_wait_common64 (
    private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x5555556202d0) at ./nptl/futex-internal.c:57
(gdb) disassemble $rip-0x10, +0x20
Dump of assembler code from 0x7ffff7f8e64b to 0x7ffff7f8e66b:
   0x00007ffff7f8e64b:  insl   (%dx),%es:(%rdi)
   0x00007ffff7f8e64c:  fbld   0x41(%rsi)
   0x00007ffff7f8e64f:  (bad)
   0x00007ffff7f8e651:  lock punpcklqdq %xmm7,%xmm5
   0x00007ffff7f8e656:  punpcklqdq %xmm8,%xmm4
=> 0x00007ffff7f8e65b:  movdqa %xmm5,(%rax)
   0x00007ffff7f8e65f:  movdqa %xmm3,(%rax,%rcx,1)
   0x00007ffff7f8e664:  movdqa %xmm4,(%rax,%rdx,1)
   0x00007ffff7f8e669:  movdqa %xmm6,(%rax,%rsi,1)
End of assembler dump.
(gdb) i reg rax
rax            0x7fffd2d06100      140736730259712
(gdb) 

Further debugging showed that address 0x7fffd2d06100 is in the range of dumb buffer provided by evdi and mmap()-ed by LLVMpipe. When running multi-threaded, accesses to dumb buffer trigger concurrent page faults - vm_insert_page() gets called from evdi_gem_fault(). Because of concurrent access, instances of vm_insert_page() call can return -EBUSY; evdi_gem_fault() returns VM_FAULT_SIGBUS.

tom-ton commented 6 months ago

Complaints about SIGBUS also here: https://github.com/swaywm/wlroots/issues/1823 Possibly the same root cause?