Bug 21630 - "barcode reader" device reproducibly causes SEGV in evdev driver
Summary: "barcode reader" device reproducibly causes SEGV in evdev driver
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Input/evdev (show other bugs)
Version: 7.4 (2008.09)
Hardware: Other All
: medium normal
Assignee: Peter Hutterer
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-08 04:37 UTC by martin
Modified: 2009-08-31 21:29 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
xorg.log from the system with the barcode reader (28.25 KB, text/x-log)
2009-05-08 04:38 UTC, martin
no flags Details
xorg.log.old from the system with the barcode reader (29.56 KB, application/x-trash)
2009-05-08 04:39 UTC, martin
no flags Details
lspci -vvnn from the system with the barcode reader (10.53 KB, application/octet-stream)
2009-05-08 04:39 UTC, martin
no flags Details
lsusb -v from the system with the barcode reader (20.90 KB, application/octet-stream)
2009-05-08 04:39 UTC, martin
no flags Details
xorg.conf from the system with the barcode reader (1.01 KB, application/octet-stream)
2009-05-08 04:40 UTC, martin
no flags Details
GDB "bt full" showing the xserver SEGV that the barcode reader causes (9.94 KB, text/plain)
2009-05-08 04:41 UTC, martin
no flags Details
evtest output (12.00 KB, text/plain)
2009-05-12 02:50 UTC, Mathieu
no flags Details
evtest output of a working barcode reader (8.00 KB, text/plain)
2009-05-14 03:59 UTC, Mathieu
no flags Details

Description martin 2009-05-08 04:37:41 UTC
(I'm forwarding this bug upstream on the behalf of another user,
for the original downstream bug report please see:
https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/370851 )

Repro steps:

0. (using ubuntu 9.04 final; probably works on all xserver 1.6.0 systems though)

1. attach barcode reader hw to X of model [ref #1]
2. scan a barcode ==> immediate segv in xserver, return to GDM, fail.


ref #1: the specific barcode reader hw model is:
http://www.rakuten.co.jp/fksystem/702994/613735/

Here is the "bt full":

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7a6d6d0 (LWP 4704)]
updateSlaveDeviceCoords (master=0x995c258, pDev=0x99e87f8)
    at ../../dix/getevents.c:168
168	../../dix/getevents.c: No such file or directory.
	in ../../dix/getevents.c
(gdb) backtrace full
#0  updateSlaveDeviceCoords (master=0x995c258, pDev=0x99e87f8)
    at ../../dix/getevents.c:168
	scr = (ScreenPtr) 0x0
	i = <value optimized out>
	lastSlave = <value optimized out>
#1  0x080a0958 in GetKeyboardValuatorEvents (events=0x95ad238, pDev=0x99e87f8, 
    type=2, key_code=13, first_valuator=0, num_valuators=0, valuators=0x0)
    at ../../dix/getevents.c:541
	numEvents = <value optimized out>
	ms = <value optimized out>
	sym = 52
	kbp = <value optimized out>
#2  0x080a0cda in GetKeyboardEvents (events=0x95ad238, pDev=0x99e87f8, type=2, 
    key_code=13) at ../../dix/getevents.c:743
No locals.
#3  0x080d817b in xf86PostKeyboardEvent (device=0x99e87f8, key_code=13, 
    is_down=1) at ../../../../hw/xfree86/common/xf86Xinput.c:931
	nevents = <value optimized out>
	i = <value optimized out>
	pointer = (DeviceIntPtr) 0x995be98
#4  0xb58893db in EvdevReadInput (pInfo=0x99b6de0) at ../../src/evdev.c:256
	ev = {time = {tv_sec = 1241755265, tv_usec = 788288}, type = 1, 
  code = 5, value = 1}
	len = <value optimized out>
	value = 1
	dx = 0
	dy = 0
	abs = 0
	button = 0
	pEvdev = (EvdevPtr) 0x99e7ce0
#5  0x080c7da7 in xf86SigioReadInput (fd=30, closure=0x99b6de0)
    at ../../../../hw/xfree86/common/xf86Events.c:311
	errno_save = 11
	sigstate = 1
#6  0x080b82cc in xf86SIGIO (sig=29)
    at ../../../../../hw/xfree86/os-support/linux/../shared/sigio.c:114
	i = 1
	ready = {fds_bits = {1073741824, 0 <repeats 31 times>}}
	to = {tv_sec = 0, tv_usec = 0}
	save_errno = 11
	r = 1
#7  <signal handler called>
No symbol table info available.
#8  0xb80c6430 in __kernel_vsyscall ()
No symbol table info available.
#9  0xb7d5e77d in ___newselect_nocancel () from /lib/tls/i686/cmov/libc.so.6
No locals.
#10 0x081329f0 in WaitForSomething (pClientsReady=0x99b3398)
    at ../../os/WaitFor.c:228
	i = <value optimized out>
	waittime = {tv_sec = 59, tv_usec = 249118}
	wt = (struct timeval *) 0xbfbe3600
	timeout = <value optimized out>
	clientsReadable = {fds_bits = {0 <repeats 32 times>}}
	clientsWritable = {fds_bits = {163428176, -1213807560, 163429268, 
    136208372, 163428200, 157825752, 157825752, 157950132, 2, 32, 2, 
    -1210183692, -1210179264, 163431936, -1078053544, -1211157066, 
    -1210179264, 163431936, 163431928, 136208372, 163431936, 163153512, 
    -1078053528, 135499809, 163431936, 136208372, -1078053464, 134696004, 
    163431936, 23069101, -1078053464, 4096}}
	curclient = <value optimized out>
	selecterr = 2264
	nready = <value optimized out>
	devicesReadable = {fds_bits = {163428176, -1235542028, -1078053720, 
    -1235570038, 163428176, 163428176, -1078053720, 135499809, -1231418896, 
    157825752, 163428200, -1232039351, 163428176, -1231312192, -1211159436, 
    134688279, 162560600, 157830496, -1211159436, 136208372, 163429260, 
    157825752, -1078053640, 135788002, 163428176, 136274600, 163431936, 
    -1210179264, 1, 32, -1078053576, -1213853672}}
	now = 429526
	someReady = 0
#11 0x0808d2be in Dispatch () at ../../dix/dispatch.c:367
	result = 0
	client = (ClientPtr) 0x9b079d0
	nready = -1
	start_tick = 360
#12 0x080722ed in main (argc=10, argv=0xbfbe3754, envp=0x0)
    at ../../dix/main.c:397
	i = <value optimized out>
	alwaysCheckForInput = {0, 1}
Comment 1 martin 2009-05-08 04:38:52 UTC
Created attachment 25633 [details]
xorg.log from the system with the barcode reader
Comment 2 martin 2009-05-08 04:39:10 UTC
Created attachment 25634 [details]
xorg.log.old from the system with the barcode reader
Comment 3 martin 2009-05-08 04:39:35 UTC
Created attachment 25635 [details]
lspci -vvnn from the system with the barcode reader
Comment 4 martin 2009-05-08 04:39:53 UTC
Created attachment 25636 [details]
lsusb -v from the system with the barcode reader
Comment 5 martin 2009-05-08 04:40:15 UTC
Created attachment 25637 [details]
xorg.conf from the system with the barcode reader
Comment 6 martin 2009-05-08 04:41:03 UTC
Created attachment 25638 [details]
GDB "bt full" showing the xserver SEGV that the barcode reader causes
Comment 7 martin 2009-05-08 04:42:29 UTC
When the barcode reader hw is attached /var/log/messages show this:

May 2 22:19:01 kumo kernel: [21888.413149] usb 2-1: USB disconnect, address 2
May 2 22:19:16 kumo kernel: [21903.328012] usb 6-2: new low speed USB device using uhci_hcd and address 2
May 2 22:19:16 kumo kernel: [21903.503092] usb 6-2: configuration #1 chosen from 1 choice
May 2 22:19:17 kumo kernel: [21903.931545] input: Guest Generic DE64-401 as /devices/pci0000:00/0000:00:1d.0/usb6/6-2/6-2:1.0/input/input7
May 2 22:19:17 kumo kernel: [21903.944051] cypress 0003:04B4:DE64.0004: input,hidraw3: USB HID v1.00 Keyboard [Guest Generic DE64-401] on usb-0000:00:1d.0-2/input0
Comment 8 martin 2009-05-08 04:53:26 UTC
This particular barcode reader previosuly worked well using Ubuntu 8.04 hardy, which shipped the following versions:

xserver-xorg-core          1.4.1~git20080131-1ubuntu9.2
xserver-xorg-input-evdev   1.2.0-1ubuntu2

Ubuntu 9.04 jaunty where the SEGV is confirmed, uses these versions:

xserver-xorg-core          1.6.0-0ubuntu14
xserver-xorg-input-evdev   2.1.1-1ubuntu4

So this is a regression.



Versions of X server and evdev in various distro releases:
https://launchpad.net/ubuntu/+source/xserver-xorg-input-evdev
https://launchpad.net/ubuntu/+source/xorg-server
Comment 9 Peter Hutterer 2009-05-08 16:29:39 UTC
please attach the output of evtest against the device file. It'll help
creating a software emulation of the device to reproduce the bug.

http://people.freedesktop.org/~whot/evtest.c
Comment 10 Mathieu 2009-05-12 02:50:51 UTC
Created attachment 25788 [details]
evtest output

Peter and Martin, please find evtest output attached, according to Martin's very detailed instructions:
sudo ./evtest /dev/input/event7 > output.txt
Comment 11 Mathieu 2009-05-14 03:59:53 UTC
Created attachment 25860 [details]
evtest output of a working barcode reader

Not sure if this could be of any help, but this is the evtest output of a working barcode reader (this one : http://item.rakuten.co.jp/fksystem/z-3021/ )
Comment 12 martin 2009-05-18 09:33:05 UTC
Peter, is there anything else you need for this bug? Will you be able to re-create the SEGV based on the data Mathieu has supplied?

It looks like updateSlaveDeviceCoords() is calling miPointerGetScreen() which returns NULL and then updateSlaveDeviceCoords() derefs that pointer trying to get the width of the screen. I'm guessing there should be a proper Screen associated with the barcode reader device?
Comment 13 Peter Hutterer 2009-05-19 21:11:16 UTC
No, I can reproduce the bug with this information. Trickier than expected, I
think it triggered 5 different bugs already, some in evdev, some in xserver.
Comment 14 Peter Hutterer 2009-07-03 17:37:27 UTC
FWIW, git master from evdev and xserver now run stable with this device. This could be interesting to cherry-pick back...
Comment 15 martin 2009-07-04 02:24:26 UTC
Terrific! Thanks a lot. In which X version(s) is the fix likely to ship? For potential cherry picking, do you have any SHA1's to recommend?

@Mathieu, if you're comfortable building X from source, it would be nice to get the fix confirmed.
Comment 16 Peter Hutterer 2009-07-04 15:23:33 UTC
(In reply to comment #15)
> Terrific! Thanks a lot. In which X version(s) is the fix likely to ship? For
> potential cherry picking, do you have any SHA1's to recommend?

not yet, I need to go through all the patches I pushed over the last weeks. There was at least one or two in evdev and a few in the server.
All the fixes will be in 1.7 though.
Comment 17 Mathieu 2009-07-06 06:13:28 UTC
Thanks Peter.

> @Mathieu, if you're comfortable building X from source

I'm afraid I'd prefer to wait for a more easy way, like a package...
Comment 18 martin 2009-07-06 13:07:25 UTC
Ok so, let's keep an eye on the xserver package for karmic (which I think will get updated to the 1.7 bits eventually). Once that's out you can just download and boot and ISO and test from that live CD:
https://launchpad.net/ubuntu/+source/xorg-server
Comment 19 Mathieu 2009-07-06 16:22:38 UTC
OK, I will check with Ubuntu Karmic then.
Comment 20 Peter Hutterer 2009-08-31 21:29:29 UTC
I'm closing this bug as FIXED. It works with current git but cherry-picking them back to 1.6.x is likely not happening. Sorry.


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.