wulf7 / libudev-devd

libudev-compatible interface for devd
9 stars 7 forks source link

tag_list is always NULL #7

Open jsm222 opened 1 month ago

jsm222 commented 1 month ago
#include <libudev.h>

int main() {
    int res;
    struct udev * context;
    struct udev_device * device;
    char const * sys_name;
    char const * subsystem;
    context = udev_new();

    device = udev_device_new_from_syspath(
       context,
       "/dev/input/event0"
    );
    if (device == NULL) {
        return 1;
    }

    printf("%d",udev_device_has_tag(device,"TAG"));
    return 0;
}
cc udev.c -I /usr/local/include/ -L/usr/local/lib -ludev

udev_new udev_device_new_from_syspath(/dev/input/event0) udev_device_get_syspath(0xbd83f41b000) /dev/input/event0 udev_device_get_sysname(0xbd83f41b000(/dev/input/event0)) event0 udev_device_get_udev(0xbd83f41b000(/dev/input/event0)) udev_device_get_syspath(0xbd83f419100) kbdmux0 udev_device_has_tag(0xbd83f41b000, TAG)

Segmentation fault (core dumped)

Program terminated with signal SIGSEGV, Segmentation fault. Address not mapped to object.

0 0x00000008216c13e6 in udev_list_entry_get_by_name (ule=0x0, name=0x200620 "TAG") at ../udev-list.c:170

170 ret = RB_FIND(udev_list, ule->list, find); (gdb) bt

0 0x00000008216c13e6 in udev_list_entry_get_by_name (ule=0x0, name=0x200620 "TAG") at ../udev-list.c:170

1 0x00000008216be853 in udev_device_has_tag (ud=0xbd83f41b000, tag=0x200620 "TAG") at ../udev-device.c:185

2 0x0000000000201829 in main ()

This causes kwin_wayland to segfault since it uses has_tag here https://invent.kde.org/plasma/kwin/-/blob/784d48ef/src/tabletmodemanager.cpp#L38

wulf7 commented 1 month ago

Thank you for report and test sample.

Please test current master. It should fix the issue.

jsm222 commented 1 month ago

It seems to fix it yes, kwin_wayland does not crash on the has_tag function.. so it starts with your fix. Thanks!