DisplayLink / evdi

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

evdi crashes DisplayLinkManager when moving mouse to connected display #446

Closed winterwurzel closed 3 months ago

winterwurzel commented 6 months ago

Description

As soon as I move the mouse cursor to a monitor connected via displaylink it crashes. Moving any type and number of windows on the screen (via keyboard shortcuts) works flawlessly.

Syslog stacktrace can be found further below.

Logs

Building module: Cleaning build area... make -j24 KERNELRELEASE=6.6.8-200.fsync.fc39.x86_64 all INCLUDEDIR=/lib/modules/6.6.8-200.fsync.fc39.x86_64/build/include KVERSION=6.6.8-200.fsync.fc39.x86_64 DKMS_BUILD=1... Signing module /var/lib/dkms/evdi/1.14.1/build/evdi.ko Cleaning build area...

evdi.ko.xz: Running module version sanity check.

MariusLer commented 5 months ago

I have the same issue.

Linux distribution and its version: Ubuntu 23.10 Linux kernel version: Linux 6.5.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:59:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux Xorg version (if used): Wayland Desktop environment in use: KDE Plasma Version 5.27 Pc: Lenovo thinkpad T14 Gen3 (AMD) Docking Station: Lenovo ThinkPad Hybrid USB_C with USB-A Dock

After a lot of crashes from driver, the issue will suddenly disappear and moving the cursor works just fine. The issue comes back after reconnecting or restarting my laptop.

DLSupportTool logs: https://displaylink.org/forum/showthread.php?t=69120

qdel commented 5 months ago

Hello,

New user of a display link dock, I face the exact same issue.

Screens are working fine (Moving glxgears using keyboard on all of them).

Did you find a workaround?

mnixry commented 4 months ago

UPDATE: It is not a bug from displaylink, it was caused by the memcpy in the following code:

https://github.com/DisplayLink/evdi/blob/9905b9bfed8b7e49befa0530bfb6e464380d938f/library/evdi_lib.c#L850-L879

Currently, I found the event->buffer_length were set to 16384 (128×128 pixels) bytes, but we can only copy 4096 (64×64 pixels) bytes from mmap before it raises SIGBUS signal.

Extra debugging will be required to determine the where the bug originated from.


Here's the relevant part of the stack trace:

DisplayLinkManager v5.8.0 (6.3.33.0)
#0  0x00007f0fca175587 n/a (libc.so.6 + 0x15b587)
#1  0x00007f0fca49101a evdi_handle_events (libevdi.so + 0x401a)
#2  0x000055c813588bee n/a (DisplayLinkManager + 0x244bee)
#3  0x000055c813465fc4 n/a (DisplayLinkManager + 0x121fc4)
#4  0x000055c8134e3c60 n/a (DisplayLinkManager + 0x19fc60)
#5  0x00007f0fca0a955a n/a (libc.so.6 + 0x8f55a)
#6  0x00007f0fca126a3c n/a (libc.so.6 + 0x10ca3c)

The issue appears to stem from this part of the code:

https://github.com/DisplayLink/evdi/blob/9905b9bfed8b7e49befa0530bfb6e464380d938f/library/evdi_lib.c#L949-L961


UPDATE: Here's an improved patch to work around the issue.

If you're encountering this problem, there's a workaround that can prevent the program from crashing:

    if (event->enabled) { 
        size_t size = event->buffer_length; 
+       size = size > 0x1000 ? 0x1000 : size; // limit the max read size to 64*64=4096 pixels
        uint64_t offset = 
            evdi_get_dumb_offset(handle, event->buffer_handle); 
        void *ptr = mmap(0, size, PROT_READ, 
                 MAP_SHARED, handle->fd, offset); 

        if (ptr != MAP_FAILED) { 
            cursor_set.buffer = malloc(size); 
            memcpy(cursor_set.buffer, ptr, size); 
            munmap(ptr, size); 
        } else { 
            evdi_log("Error: mmap failed with error: %s", strerror(errno)); 
        } 
    } 

With this workaround, the mouse cursor may only display partially on the screen (but at least it won't crash). You can try adjusting the cursor size in the KDE appearance configuration, which might make the cursor fully visible.

dclasen-qd commented 3 months ago

Same issue over here using a DELL D6000 Dock. The workaround, setting the env variable KWIN_DRM_NO_AMS=1, mentioned in https://github.com/DisplayLink/evdi/issues/459#issuecomment-1980882934 fixed the crashes of displaylink.service.

winterwurzel commented 3 months ago

Same issue over here using a DELL D6000 Dock. The workaround, setting the env variable KWIN_DRM_NO_AMS=1, mentioned in #459 (comment) fixed the crashes of displaylink.service.

workaround works, thanks

displaylink-emajewsk commented 3 months ago

Fixed in 1.14.3