Bug 323081 - KDE crashes when a Sixaxis or DualShock 3 controller is unplugged.
Summary: KDE crashes when a Sixaxis or DualShock 3 controller is unplugged.
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 4.10.95
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Thomas Lübking
URL: https://help.ubuntu.com/community/Six...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-01 17:52 UTC by Rebecca Menessec
Modified: 2013-08-02 21:52 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Backtraces (5.92 KB, application/force-download)
2013-08-01 19:07 UTC, Rebecca Menessec
Details
ltrace of Dolphin crashing (1.10 KB, text/plain)
2013-08-01 20:25 UTC, Rebecca Menessec
Details
strace of Dolphin crashing (2.61 KB, application/x-bzip)
2013-08-01 20:25 UTC, Rebecca Menessec
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rebecca Menessec 2013-08-01 17:52:18 UTC
All KDE components crash when a Sony DualShock 3 (tested) or Sixaxis (untested) controller is connected to the host system via USB, then disconnected. This does not occur for Bluetooth HID connections, although the controller in question has been paired via Bluetooth as well.

(Tested both USB disconnection while BT connected, and USB disconnection while BT not connected.)

Xorg.0.log:

[   127.417] (II) config/udev: Adding input device Sony PLAYSTATION(R)3 Controller (/dev/input/js0)
[   127.417] (II) No input driver specified, ignoring this device.
[   127.417] (II) This device may have been added with another device file.
[   127.418] (II) config/udev: Adding input device Sony PLAYSTATION(R)3 Controller (/dev/input/event16)
[   127.418] (II) No input driver specified, ignoring this device.
[   127.418] (II) This device may have been added with another device file.

No other events occur until the controller is re-connected.

Application crash reporter does not appear to have captured anything useful:

Application: knotify4 (4.0)
KDE Platform Version: 4.10.95
Qt Version: 4.8.4
Operating System: Linux 3.8.0-28-generic x86_64
Distribution: Ubuntu 13.04

-- Information about the crash:
<In detail, tell us what you were doing  when the application crashed.>

The crash can be reproduced every time.

-- Backtrace:
A useful backtrace could not be generated

Report to https://bugs.kde.org/

Reproducible: Always

Steps to Reproduce:
Step 1: Connect a DualShock3 or Sixaxis controller via USB, following the instructions available at https://help.ubuntu.com/community/Sixaxis , and including the section "Configuring newer versions of X.Org (XServer >= 1.5) with HAL and automatic hot-plugging"
Step 2: Unplug the controller.
Step 3: All observable KDE components segfault: kwin, knotify, kmix, Dolphin, etc.
Step 3a: No other applications appear to crash.
Comment 1 Rebecca Menessec 2013-08-01 17:58:16 UTC
This crash condition does not appear to be triggered when any other input (/dev/input/event/*) devices are disconnected. Xorg.0.log does not report any other devices being ignored. This may only apply to devices with "no driver", or only to the very specific case of the DualShock 3/ Sixaxis controllers, which are not proper USB HID gamepad devices, nor proper BT HID gamepad devices.

Neither the kernel log nor the Xorg logs report any anomalies regarding USB, BT, or the specific HID sub-drivers.
Comment 2 Thomas Lübking 2013-08-01 18:24:20 UTC
> All KDE components crash

This means you're back at the login screen?
Comment 3 Rebecca Menessec 2013-08-01 18:28:27 UTC
(In reply to comment #2)
> > All KDE components crash
> 
> This means you're back at the login screen?

Actually, the KDE environment restarts and recovers, and presents KDE app crash reporters for all the segfaulted components. I just installed the debug symbols, and I'm trying to get at least one useful backtrace, preferably for kwin.
Comment 4 Rebecca Menessec 2013-08-01 18:30:52 UTC
...after disconnecting and reconnecting the DualShock 3 in the same session, only knotify, kmix, and Dolphin crash. So far. This is after installing the debug packages. I'm getting ready to close the KDE session entirely to try again.
Comment 5 Thomas Lübking 2013-08-01 18:35:12 UTC
Feel free to attach any bugreport - this is probably in Qt input handling.
Comment 6 Rebecca Menessec 2013-08-01 19:07:42 UTC
Created attachment 81513 [details]
Backtraces
Comment 7 Rebecca Menessec 2013-08-01 19:10:35 UTC
Unfortunately, the KDE crash reporter does not like any of these backtraces. I'm not sure what they're supposed to look like. I installed the following packages before generating the backtraces:

kate-dbg kde-baseapps-dbg kde-baseapps-dbg kde-runtime-dbg kde-workspace-dbg kdeadmin-dbg kdeartwork-dbg kdebase-runtime-dbg kdelibs5-dbg kdenetwork-dbg kdepim-dbg kdepim-runtime-dbg kdepimlibs-dbg kdetoys-dbg konsole-dbg libc6-dbg:amd64 libqt4-dbg
Comment 8 Thomas Lübking 2013-08-01 19:59:40 UTC
(In reply to comment #7)
> Unfortunately, the KDE crash reporter does not like any of these backtraces.
> I'm not sure what they're supposed to look like.

Something that does not say "crash in unknown location" :-(

Thread 1 (Thread 0x7f824e8c37c0 (LWP 88797)):
[KCrash Handler]
#6  0x0000000000000000 in ?? ()
#7  0x0000000000000000 in ?? ()

> I installed the following packages before generating the backtraces:
That's not the problem, the stack is corrupt.

ltracing or stracing on crash prone application and causing the crash might give a hint what causes the crash.

Since it's HID related, can you also crash eg. a "dolphin --noxim" instance?
(That's a very wild guess, don't expect anything or focus on this direction)
Comment 9 Rebecca Menessec 2013-08-01 20:24:35 UTC
I'm attaching an strace excerpt with a little bit of identifying information removed (username = "user", hostname = "localhost), and a very short ltrace with some other identifying information removed (should be obvious from device names).
Comment 10 Rebecca Menessec 2013-08-01 20:25:14 UTC
Created attachment 81520 [details]
ltrace of Dolphin crashing
Comment 11 Rebecca Menessec 2013-08-01 20:25:49 UTC
Created attachment 81521 [details]
strace of Dolphin crashing
Comment 12 Rebecca Menessec 2013-08-01 20:26:31 UTC
Launching Dolphin with --noxim had no effect; it crashed even with the extra flag.
Comment 13 Thomas Lübking 2013-08-02 09:38:05 UTC
Try ltracing knotify4 instead (forgot that kdeinit makes ltracing more complex) - in doubt only valgrind might help.

According to the strace the last system operation was a (failed) resolution of the symlink /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/input/input29/driver - but i've no idea why that should happen (esp. in other things than dolphin) or cause a crash (phonon/pulse/gstreamer maybe *shrug*)
Comment 14 Rebecca Menessec 2013-08-02 17:51:41 UTC
I saw it. I think that supports my theory that this only happens to devices logged by xorg as having "no driver". Can you glance at the Ubuntu instructions I linked in the original report post and tell me if that's actually the correct way to configure xorg for hotpluggable devices?

At minimum, hald is never started in Ubuntu 13.04, but the instructions assume it exists. I just found a low-priority bug filed against it: https://bugs.launchpad.net/ubuntu/+source/hal/+bug/1192171

My working theory is that, with "no driver", xorg is failing to notify KDE or Qt about device plug events on DualShock 3 disconnection, leading to the crash. While Qt should be robust against this problem, I think xorg is the original cause.

The Ubuntu bug mentions that hald is strongly deprecated. That being the case, what should be done to ensure xorg is correctly configured for hotplugging this type of device? Is there a way to convert hal rules for whatever replaced it?

Also, I can't figure out who to copy to make sure the Kubuntu team is looking at this or the other bug. Help?
Comment 15 Thomas Lübking 2013-08-02 19:01:45 UTC
(In reply to comment #14)
> At minimum, hald is never started in Ubuntu 13.04

HAL is deprecated, outdated, unmaintained - "gone"
You'd usually "do what needs to be done on strage devices" by a udev rule.

> The Ubuntu bug mentions that hald is strongly deprecated.
Yes, it's more or less dead (since quite a while)

> That being the case, what should be done to ensure xorg is correctly configured for hotplugging this type of device?
I don't think you'll require udev or something here - the HAL rule seems to mostly setup the device what would today be done by some /etc/X11/xorg.conf.d/ snippet - mostly equal to the "static" configuration, but using the "MatchIsJoystick" "MatchProduct" MatchVendor" entries instead of
Option          "Device"        "/dev/input/by-id/usb-Broadcom_Corp_BCM92045B3_ROM_00191567386A-event-joystick"

Compare eg. /etc/X11/xorg.conf.d/10-evdev.conf for how this is done.

> Also, I can't figure out who to copy to make sure the Kubuntu team is
> looking at this or the other bug. Help?
If there's a mail address you can connect to get them aware, you can just add it on the top right of this page.
If not, you'd probably just open a bug on launchpad and link this one
https://bugs.kde.org/show_bug.cgi?id=323081

If you happen to figure what actually crashes here, please report back.
Do btw. "plain" Qt applications (eg. qupzilla, smplayer or so?) crash as well?
Comment 16 Rebecca Menessec 2013-08-02 19:23:36 UTC
(In reply to comment #15)
> If you happen to figure what actually crashes here, please report back.
> Do btw. "plain" Qt applications (eg. qupzilla, smplayer or so?) crash as
> well?

All the apps listed in the traces Zip crashed. Nothing else crashes. I've got Clementine installed, for example, and it doesn't crash. It's purely the core KDE processes.
Comment 17 Rebecca Menessec 2013-08-02 20:49:11 UTC
So much for my theory. This does get xorg to assign the evdev driver for the DualShock 3, but it both breaks my trackpad and doesn't fix the crashes. Reverted. I'm very curious to know why it would break the trackpad, given how carefully I'm locking this section down to apply to the DualShock 3. Works with and without "MatchIsJoystick". Just for the record:

Section "InputClass"
	Identifier "DualShock3"
	Driver "evdev"
	Option "MatchDevicePath" "PLAYSTATION"
	Option "MatchVendor" "Sony"
	Option "MatchProduct" "Controller"
	Option "MatchIsJoystick" "true"
	Option "Floating" "false"
	# Option "StartKeysEnabled" "False"		#Disable mouse
	# Option "StartMouseEnabled" "False"	#support
# EndSection
Comment 18 Thomas Lübking 2013-08-02 21:52:05 UTC
Taking off-list

-----

Define "broken" - is the touchpad no longer listed in "xinput list"?

This
	  Option "MatchDevicePath" "PLAYSTATION"

Is for pretty much sure wrong - it should rather read like
   	Option "MatchDevicePath" "/dev/input/*"
or similar (if you needed to match by device)

SImilarily
	Option "MatchVendor" "Sony"
	Option "MatchProduct" "Controller"

should be some hex ids - you'll likely see them in "lsusb" ("1234:5678", before colon is vendor, after is product)

So basically the rule would likely never apply.

I suggest to ignore vendor, product and path for the moment and only MatchIsJoystick - it's what the HAL rule does as well.

	Option "Floating" "false"
This is the default anyway.

This
  Driver "evdev"
contradicts the ubuntu page you linked - should be 
  Driver "joystick"

instead - and of course you would likely want to have the other options:

#The previous line will also be system specific, but you will most likely find the Sixaxis at /dev/input/js0
# Map Button 16 - square
        Option          "MapButton16"   "button=3"
# Map Button 15 - x
        Option          "MapButton15"   "button=1"
# Map Button 11 - L1
        Option          "MapButton11"   "key=Alt_L,Left"
# Map Button 12 - R1
        Option          "MapButton12"   "key=Alt_L,Right"
        Option          "MapAxis1"      "mode=relative axis=2.0x deadzone=3000"
        Option          "MapAxis2"      "mode=relative axis=2.0y deadzone=3000"

I assume the device is just added and evdev handled and interfers with the trackpad.
The used driver will be listed in /var/log/Xorg.0.log