Bug 100976 - libinput-1.7.2 segfault when built with clang
Summary: libinput-1.7.2 segfault when built with clang
Status: RESOLVED FIXED
Alias: None
Product: Wayland
Classification: Unclassified
Component: libinput (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Peter Hutterer
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-09 16:32 UTC by Armin K
Modified: 2017-05-11 00:54 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Armin K 2017-05-09 16:32:32 UTC
As the title says. When built with gcc, it's fine. Backtrace when running libinput-list-devices is below (it also crashes X server when using xf86-input-libinput):

Starting program: /usr/bin/libinput-list-devices 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
fallback_dispatch_create (libinput_device=<optimized out>) at evdev.c:1809
1809		if (fallback_dispatch_init_slots(dispatch, device) == -1) {
(gdb) bt
#0  fallback_dispatch_create (libinput_device=<optimized out>) at evdev.c:1809
#1  evdev_configure_device (device=<optimized out>) at evdev.c:2680
#2  evdev_device_create (seat=<optimized out>, udev_device=<optimized out>) at evdev.c:2909
#3  0x00007ffff7bcc611 in device_added (udev_device=0x62c8c0, input=0x611f60, seat_name=0x7ffff7bd23db <default_seat_name> "default") at udev-seat.c:85
#4  0x00007ffff7bcc2ed in udev_input_add_devices (udev=<optimized out>, input=<optimized out>) at udev-seat.c:154
#5  udev_input_enable (libinput=0x611f60) at udev-seat.c:264
#6  0x00007ffff7bcc149 in libinput_udev_assign_seat (libinput=0x611f60, seat_id=<optimized out>) at udev-seat.c:392
#7  0x0000000000403b4a in open_udev (interface=<optimized out>, userdata=<optimized out>, seat=<optimized out>, verbose=<optimized out>) at shared.c:411
#8  tools_open_backend (context=<optimized out>) at shared.c:488
#9  0x0000000000402e56 in main (argc=<optimized out>, argv=<optimized out>) at libinput-list-devices.c:393
Comment 1 Armin K 2017-05-09 16:46:01 UTC
fallback_dispatch_init_slots (dispatch=<optimized out>, device=<optimized out>) at evdev.c:1714
1714		struct libevdev *evdev = device->evdev;

device might be invalid, container_of as-is might not be usable with clang.
Comment 2 Armin K 2017-05-09 16:52:51 UTC
Confirmed. It is working when I replace the one in src/libinput-util.h with the following one:

https://cgit.freedesktop.org/mesa/drm/tree/util_double_list.h#n110
Comment 4 Peter Hutterer 2017-05-11 00:54:01 UTC
commit 3925936969e993709c832731343ace3ff5e695d0
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed May 10 12:33:10 2017 +1000

    util: fix container_of() macro


Planned for versions: 1.8, 1.7.3


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.