Bug 234638 - x11/libinput: crashes in devel/libudev-devd on device enumeration
Summary: x11/libinput: crashes in devel/libudev-devd on device enumeration
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-x11 mailing list
URL:
Keywords: crash
Depends on:
Blocks:
 
Reported: 2019-01-05 17:06 UTC by Jan Beich
Modified: 2019-01-06 09:40 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (x11)
koobs: merge-quarterly?


Attachments
libinput list-devices output (3.59 KB, text/plain)
2019-01-05 18:26 UTC, Jan Beich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2019-01-05 17:06:01 UTC
$ libinput list-devices
Thread 1 received signal SIGBUS, Bus error.
0x00000008002b61af in udev_list_RB_MINMAX (head=0x800c46f48, val=-1) at udev-list.c:163
163     RB_GENERATE(udev_list, udev_list_entry, link, udev_list_entry_cmp);
(gdb) bt full
#0  0x00000008002b61af in udev_list_RB_MINMAX (head=0x800c46f48, val=-1) at udev-list.c:163
        tmp = 0x726f666d6f432074
        parent = 0x726f666d6f432074
#1  0x00000008002b62ea in udev_list_entry_get_first (ul=0x800c46f48) at udev-list.c:112
No locals.
#2  0x00000008002b47d0 in udev_device_get_property_value (ud=0x800c46f40, property=0x80025c7cb "WL_OUTPUT")
    at udev-device.c:199
        key = 0x800c2b700 "\003"
        value = 0x800c9dc00 ""
        entry = 0xd
#3  0x00000008002a2275 in device_added (udev_device=0x800c46f40, input=0x800c2b700,
    seat_name=0x80025eaa0 <default_seat_name> "default") at ../src/udev-seat.c:104
        device = 0x800c9dc00
        devnode = 0x800c46f78 "00/1.70, addr 3"
        sysname = 0x800c46f83 "dr 3"
        device_seat = 0x80025ea9a <default_seat> "seat0"
        output_name = 0x800c46f78 "00/1.70, addr 3"
        seat = 0x800c8e000
#4  0x00000008002a25e8 in udev_input_add_devices (input=0x800c2b700, udev=0x800c445a0) at ../src/udev-seat.c:164
        e = 0x800c3c510
        entry = 0x800c26280
        device = 0x800c46f40
        path = 0x800c262a8 "/dev/input/event4"
        sysname = 0x800c46f83 "dr 3"
#5  0x00000008002a1cab in udev_input_enable (libinput=0x800c2b700) at ../src/udev-seat.c:274
        input = 0x800c2b700
        udev = 0x800c445a0
        fd = 5
#6  0x00000008002a1a85 in libinput_udev_assign_seat (libinput=0x800c2b700, seat_id=0x202c9b "seat0")
    at ../src/udev-seat.c:398
        input = 0x800c2b700
#7  0x0000000000205aec in tools_open_udev (seat=0x202c9b "seat0", verbose=false, grab=0x7fffffffe19f)
    at ../tools/shared.c:274
        li = 0x800c2b700
        udev = 0x800c445a0
#8  0x00000000002059e6 in tools_open_backend (which=BACKEND_UDEV, seat_or_device=0x202c9b "seat0",
    verbose=false, grab=0x7fffffffe19f) at ../tools/shared.c:323
        li = 0x0
#9  0x0000000000204434 in main (argc=1, argv=0x7fffffffe230) at ../tools/libinput-list-devices.c:392
        li = 0x0
        ev = 0x7fffffffe228
        grab = false

$ rm /dev/input/event[47]
$ libinput list-devices
Device:           System keyboard multiplexer
Kernel:           /dev/input/event0
Group:            1
Seat:             seat0, default
Capabilities:     keyboard 
[...]

$ libevdev_describe /dev/input/event4
name: "Microsoft Comfort Curve Keyboard 3000, class 0/0, rev 2.00/1.70, addr 3"
bustype: 0x3
vendor: 0x45e
product: 0x780

$ libevdev_describe /dev/input/event7
name: "Kingsis Peripherals ZOWIE Gaming mouse, class 0/0, rev 2.00/0.01, addr 5"
bustype: 0x3
vendor: 0x1af3
product: 0x1
Comment 1 Greg V 2019-01-05 17:10:53 UTC
Which version of libudev-devd do you have?
Comment 2 Jan Beich freebsd_committer 2019-01-05 17:16:17 UTC
$ pkg info -x libudev libinput
libudev-devd-0.4
libinput-1.11.3
Comment 3 Greg V 2019-01-05 17:28:47 UTC
hm, actually, I definitely remember these crashes on my desktop.

I never found out the root cause, but they don't happen with my new sysctl based property lookup:

https://reviews.freebsd.org/D18694 + https://github.com/FreeBSDDesktop/libudev-devd/pull/8

( https://github.com/myfreeweb/freebsd-ports-dank/blob/8e51b0718b2e92fdc96861e1150bcc80a9c8b12b/devel/libudev-devd/Makefile — the libudev-devd part as a port, of course still needs the kernel part )
Comment 4 Jan Beich freebsd_committer 2019-01-05 17:39:23 UTC
Maybe this is due to uhid(4) duplicates that libudev stumbles translating back to /dev/input/eventN. I'll try your patch next.

$ for f in /dev/input/*; do sudo ./libevdev_name $f; done
/dev/input/event0: System keyboard multiplexer
/dev/input/event1: System mouse
/dev/input/event2: AT keyboard
/dev/input/event3: Logitech USB Laser Mouse, class 0/0, rev 2.00/31.00, addr 2
/dev/input/event4: Microsoft Comfort Curve Keyboard 3000, class 0/0, rev 2.00/1.70, addr 3
/dev/input/event5: CM Storm Quickfire Rapid i, class 0/0, rev 1.10/1.22, addr 4
/dev/input/event6: CM Storm Quickfire Rapid i, class 0/0, rev 1.10/1.22, addr 4
/dev/input/event7: Kingsis Peripherals ZOWIE Gaming mouse, class 0/0, rev 2.00/0.01, addr 5
Comment 5 Greg V 2019-01-05 17:45:33 UTC
(In reply to Jan Beich from comment #4)

libudev-devd doesn't care about uhid at all. When evdev is available, it only touches evdev.

> sudo

oh btw, if your user doesn't have permissions to /dev/input/*, you can try adding the permissions first
Comment 6 Jan Beich freebsd_committer 2019-01-05 17:56:48 UTC
(In reply to Greg V from comment #3)
> https://reviews.freebsd.org/D18694 + https://github.com/FreeBSDDesktop/libudev-devd/pull/8

Doesn't help: crashes in the same place.

$ sysctl -a | fgrep bustype
dev.input.7.input_id: { bustype = 0x0003, vendor = 0x1af3, product = 0x0001, version = 0x0000 }
dev.input.6.input_id: { bustype = 0x0003, vendor = 0x2516, product = 0x0020, version = 0x0000 }
dev.input.5.input_id: { bustype = 0x0003, vendor = 0x2516, product = 0x0020, version = 0x0000 }
dev.input.4.input_id: { bustype = 0x0003, vendor = 0x045e, product = 0x0780, version = 0x0000 }
dev.input.3.input_id: { bustype = 0x0003, vendor = 0x046d, product = 0xc062, version = 0x0000 }
dev.input.2.input_id: { bustype = 0x0011, vendor = 0x0001, product = 0x0001, version = 0x0000 }
dev.input.1.input_id: { bustype = 0x0006, vendor = 0x0000, product = 0x0000, version = 0x0000 }
dev.input.0.input_id: { bustype = 0x0006, vendor = 0x0000, product = 0x0000, version = 0x0000 }
Comment 7 Greg V 2019-01-05 18:06:10 UTC
OH WAIT! libinput in ports currently has the reopen patch (https://github.com/freebsd/freebsd-ports/blob/master/x11/libinput/files/patch-src_evdev.c)

Can you try

- removing that

- the port from here https://github.com/myfreeweb/freebsd-ports-dank/tree/lite/x11/libinput
Comment 8 Jan Beich freebsd_committer 2019-01-05 18:26:40 UTC
Created attachment 200808 [details]
libinput list-devices output

(In reply to Greg V from comment #7)
> - removing x11/libinput/files/patch-src_evdev.c

I confirm, this fixes the crash. Attached successful output just in case.
Comment 9 Jan Beich freebsd_committer 2019-01-05 18:37:52 UTC
(In reply to Greg V from comment #7)
> - the port from here https://github.com/myfreeweb/freebsd-ports-dank/tree/lite/x11/libinput

I confirm, freebsd-ports-dank@e659ae54b705 also fixes the issue unlike attachment 200661 [details].
Comment 10 Greg V 2019-01-05 18:40:58 UTC
(In reply to Jan Beich from comment #9)

yeah attachment 200661 [details] still includes patch-src_evdev.c with my old workaround for /dev/input permissions
Comment 11 commit-hook freebsd_committer 2019-01-05 19:39:27 UTC
A commit references this bug:

Author: zeising
Date: Sat Jan  5 19:38:53 UTC 2019
New revision: 489372
URL: https://svnweb.freebsd.org/changeset/ports/489372

Log:
  x11/libinput: Fix crash when listing devices

  Fix a crash in x11/libinput when listing devices with libinput list-devices.
  This is done by removing an old patch previously used to work arond
  permission issues with /dev/input/*

  PR:		234638
  Reported by:	Jan Beich
  Fix from:	Greg V
  Reviewed by:	Greg V
  MFH:		2019Q1

Changes:
  head/x11/libinput/Makefile
  head/x11/libinput/files/patch-src_evdev.c
Comment 12 Niclas Zeising freebsd_committer 2019-01-05 19:39:50 UTC
Fix committed.  Closing this.
Comment 13 Kubilay Kocak freebsd_committer freebsd_triage 2019-01-06 02:22:46 UTC
Re-open pending MFH commit
Comment 14 commit-hook freebsd_committer 2019-01-06 09:38:24 UTC
A commit references this bug:

Author: zeising
Date: Sun Jan  6 09:37:37 UTC 2019
New revision: 489451
URL: https://svnweb.freebsd.org/changeset/ports/489451

Log:
  MFH: r489372

  x11/libinput: Fix crash when listing devices

  Fix a crash in x11/libinput when listing devices with libinput list-devices.
  This is done by removing an old patch previously used to work arond
  permission issues with /dev/input/*

  PR:		234638
  Reported by:	Jan Beich
  Fix from:	Greg V
  Reviewed by:	Greg V

  Approved by:	ports-secteam (miwi)

Changes:
_U  branches/2019Q1/
  branches/2019Q1/x11/libinput/Makefile
  branches/2019Q1/x11/libinput/files/patch-src_evdev.c
Comment 15 Niclas Zeising freebsd_committer 2019-01-06 09:40:16 UTC
Merged, closing this.

@koobs, sorry, I wasn't aware of the MFH flag.  I'll try to remember for next time. :)