Bug 310341 - Keyboard layout set incorrectly. System settings crash when editing "Variant"
Summary: Keyboard layout set incorrectly. System settings crash when editing "Variant"
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Unclassified
Component: kcm_keyboard_layout (show other bugs)
Version: 1.0
Platform: Ubuntu Packages Linux
: NOR crash (vote)
Target Milestone: ---
Assignee: Andriy Rysin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-19 14:28 UTC by Alex Leach
Modified: 2013-02-13 12:47 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.10.1


Attachments
New crash information added by DrKonqi (6.51 KB, text/plain)
2013-01-31 18:19 UTC, Diggory Hardy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Leach 2012-11-19 14:28:19 UTC
Application: systemsettings (1.0)
KDE Platform Version: 4.9.2
Qt Version: 4.8.3
Operating System: Linux 3.5.0-19-generic x86_64
Distribution: Ubuntu 12.10

-- Information about the crash:
- What I was doing when the application crashed:

Was in System Settings -> Input Devices -> Keyboard -> Layouts.
The settings looked correct, but weren't acting so. KDE is using the US layout, when I have the UK layout configured... So I reset the options back to the Defaults, which clears all the Layouts. After adding a new layout, I double-clicked on the Variant field, which was empty, and crash!

- Unusual behavior I noticed:
The US keyboard layout is in effect, when the UK keyboard layout is what is configured. This first happened yesterday, after a kernel (3.5.0-19-generic) and graphics driver (cuda developer drivers 304.54) upgrade. I noticed that in /etc/default/keyboard, XKBLAYOUT was set to "us", so I changed this to "uk", and rebooted. Everything then worked fine yesterday, until I turned my computer on this morning. XKBLAYOUT is still "uk", but the "us" layout is back in effect.

When trying to submit this bug report, during the Launchpad login step, it said "kded is not running"... So I've just started kded4 from the command line, and that allowed me to login with Dr Konqi. I thought that now I might be able to change the keyboard layout properly, but when I changed the System Settings layout, this popped up in the terminal:-

Error loading new keyboard description
kded(16739): Failed to run "/usr/bin/setxkbmap -layout uk" return code: 251


- Custom settings of the application:

UK keyboard layout. Generic 105 key (Intl) PC

-- Backtrace:
Application: System Settings (systemsettings), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[KCrash Handler]
#6  QList (l=..., this=0x7fffb6641d10) at /usr/include/qt4/QtCore/qlist.h:122
#7  QForeachContainer (t=..., this=0x7fffb6641d10) at /usr/include/qt4/QtCore/qglobal.h:2367
#8  populateComboWithVariants (rules=<optimized out>, layout=..., combo=0x19bfaf0) at ../../../kcontrol/keyboard/kcm_view_models.cpp:304
#9  VariantComboDelegate::createEditor (this=<optimized out>, parent=<optimized out>, index=...) at ../../../kcontrol/keyboard/kcm_view_models.cpp:323
#10 0x00007fcfdaa77002 in QAbstractItemViewPrivate::editor (this=this@entry=0x1f44d30, index=..., options=...) at itemviews/qabstractitemview.cpp:4020
#11 0x00007fcfdaa771c5 in QAbstractItemViewPrivate::openEditor (this=this@entry=0x1f44d30, index=..., event=event@entry=0x0) at itemviews/qabstractitemview.cpp:4196
#12 0x00007fcfdaa774e9 in QAbstractItemView::edit (this=this@entry=0x1f2e060, index=..., trigger=trigger@entry=QAbstractItemView::DoubleClicked, event=event@entry=0x7fffb6642b30) at itemviews/qabstractitemview.cpp:2584
#13 0x00007fcfdaa71585 in QAbstractItemView::mouseDoubleClickEvent (this=0x1f2e060, event=0x7fffb6642b30) at itemviews/qabstractitemview.cpp:1847
#14 0x00007fcfda5b586a in QWidget::event (this=0x1f2e060, event=0x7fffb6642b30) at kernel/qwidget.cpp:8375
#15 0x00007fcfda964b66 in QFrame::event (this=0x1f2e060, e=0x7fffb6642b30) at widgets/qframe.cpp:557
#16 0x00007fcfdaa7059b in QAbstractItemView::viewportEvent (this=0x1f2e060, event=0x7fffb6642b30) at itemviews/qabstractitemview.cpp:1644
#17 0x00007fcfd99096d6 in QCoreApplicationPrivate::sendThroughObjectEventFilters (this=<optimized out>, receiver=0x1f1fbd0, event=0x7fffb6642b30) at kernel/qcoreapplication.cpp:1025
#18 0x00007fcfda565e6c in QApplicationPrivate::notify_helper (this=this@entry=0x1a1d360, receiver=receiver@entry=0x1f1fbd0, e=e@entry=0x7fffb6642b30) at kernel/qapplication.cpp:4558
#19 0x00007fcfda56ab6b in QApplication::notify (this=<optimized out>, receiver=0x1f1fbd0, e=0x7fffb6642b30) at kernel/qapplication.cpp:4105
#20 0x00007fcfdb26e1d6 in KApplication::notify (this=0x7fffb66437a0, receiver=0x1f1fbd0, event=0x7fffb6642b30) at ../../kdeui/kernel/kapplication.cpp:311
#21 0x00007fcfd990956e in QCoreApplication::notifyInternal (this=0x7fffb66437a0, receiver=0x1f1fbd0, event=0x7fffb6642b30) at kernel/qcoreapplication.cpp:915
#22 0x00007fcfda566cd3 in sendEvent (event=<optimized out>, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#23 QApplicationPrivate::sendMouseEvent (receiver=0x1f1fbd0, event=0x7fffb6642b30, alienWidget=0x1f1fbd0, nativeWidget=0x19c2ca0, buttonDown=0x7fcfdb042308 <qt_button_down>, lastMouseReceiver=..., spontaneous=true) at kernel/qapplication.cpp:3173
#24 0x00007fcfda5e4554 in QETWidget::translateMouseEvent (this=this@entry=0x19c2ca0, event=event@entry=0x7fffb66432b0) at kernel/qapplication_x11.cpp:4622
#25 0x00007fcfda5e344f in QApplication::x11ProcessEvent (this=0x7fffb66437a0, event=0x7fffb66432b0) at kernel/qapplication_x11.cpp:3737
#26 0x00007fcfda60afa2 in x11EventSourceDispatch (s=0x19bd710, callback=0x0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:146
#27 0x00007fcfd299bab5 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#28 0x00007fcfd299bde8 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#29 0x00007fcfd299bea4 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#30 0x00007fcfd9937bf6 in QEventDispatcherGlib::processEvents (this=0x1946ad0, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#31 0x00007fcfda60ac1e in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#32 0x00007fcfd99082bf in QEventLoop::processEvents (this=this@entry=0x7fffb6643680, flags=...) at kernel/qeventloop.cpp:149
#33 0x00007fcfd9908548 in QEventLoop::exec (this=0x7fffb6643680, flags=...) at kernel/qeventloop.cpp:204
#34 0x00007fcfd990d708 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1187
#35 0x000000000040a98e in main (argc=5, argv=0x7fffb66438e8) at ../../../systemsettings/app/main.cpp:49

Reported using DrKonqi
Comment 1 Diggory Hardy 2013-01-31 18:19:52 UTC
Created attachment 76842 [details]
New crash information added by DrKonqi

systemsettings (1.0) on KDE Platform 4.9.5 using Qt 4.8.3

- What I was doing when the application crashed:
Exactly the same as above.

- Custom settings of the application:
I have a custom keyboard layout set (https://github.com/dhardy/keyboard) via /etc/default/keyboard and setxkbmap. KDE config shows the name of the layout but not the variant (which is explicitly set).

Additionally, every so often while using KDE, the keyboard layout gets changed without me asking (not sure if this is KDE or something else and not sure if the layout selected is a different variant or an older version of the same layout/variant, but neither checking at config files nor running setupcon is any help). This may or may not be related.

-- Backtrace (Reduced):
#6  QList (l=..., this=0x7fff927bd4a0) at /usr/include/qt4/QtCore/qlist.h:122
#7  QForeachContainer (t=..., this=0x7fff927bd4a0) at /usr/include/qt4/QtCore/qglobal.h:2367
#8  populateComboWithVariants (rules=<optimized out>, layout=..., combo=0x2c83d40) at ../../../kcontrol/keyboard/kcm_view_models.cpp:304
#9  VariantComboDelegate::createEditor (this=<optimized out>, parent=<optimized out>, index=...) at ../../../kcontrol/keyboard/kcm_view_models.cpp:323
#10 0x00007f4b3c477002 in QAbstractItemViewPrivate::editor (this=this@entry=0x2a53050, index=..., options=...) at itemviews/qabstractitemview.cpp:4020
Comment 2 Andriy Rysin 2013-01-31 23:10:53 UTC
Alex, I don't have /etc/default/keyboard file on my Fedora 18 so I can't really reproduce what you're trying to do but I here's what I see:
* You're trying to mix two systems to configure layout: /etc/default/keyboard is probably handled by Ubuntu and is system-wide setting, KDE system settings will configure layout only for current user
* I tried to do what you're doing in system settings and didn't see the crash - either I am not quite following your steps or your system has some problems
* Try to turn "Configure layouts" off in KDE and let the system do it (via /etc/default/keyboard) - if it works, then it means configuring layouts is broken in your KDE build and you can just use system-wide settings; if it's still broken, then it's not related to KDE and something else is resetting your keyboard
Comment 3 Andriy Rysin 2013-01-31 23:24:37 UTC
Diggory, in some places if the variant chosen is the default its name won't be shown, not sure if it applies to your situation.
If you configured your layout via system settings, KDE will reapply the configuration if new keyboard is attached. If you see the not-requested switch happening again please attach your .xsession-errors and ~/.kde*/share/config/kxkbrc files.

Also it looks like in both crashes the problem is missing description for selected layout so please attach /usr/share/X11/xkb/rules/evdev.xml and I'll try to take a look.
Comment 4 Alex Leach 2013-02-01 02:41:44 UTC
Forgot I submitted this.. But I do remember noticing that when I had keyboard localisation issues, kded wasn't running. When I started kded from the command line, whilst already logged in to KDE, then everything started working correctly.

I've just retraced the steps I posted above, and the Variant field is populated. There is no crash, and everything seems to be working fine. Suppose I could kill kded and try it again, but that sounds dangerous, especially whilst I've got all these windows open!

I've just grepped 'description>\s*<' against evdev.xml, and there don't appear to be any empty descriptions fields. Maybe a missing one? The last mod time of the file was just two days ago, so any bugs in it would no doubt have since been fixed.
Comment 5 Andriy Rysin 2013-02-01 03:36:14 UTC
Thanks, Alex, it's not empty <description> per se, it would be probably missing layout or missing variant in the xml. But if everything is working than I would rather spend some time on other issue :)
Comment 6 Diggory Hardy 2013-02-01 10:17:09 UTC
Andriy, you're right that evdev.xml is missing a description for my layout.

Disabling layout configuration in KDE system settings isn't the answer: it is disabled, so the unwanted switches are probably part of Debian console setup. I don't see anything in .xsession-errors related and the kxbrc file contains just:

[Layout]
DisplayNames=
LayoutList=
LayoutLoopCount=-1
Model=thinkpad60
ResetOldOptions=false
ShowFlag=false
ShowLabel=true
ShowLayoutIndicator=false
ShowSingle=false
SwitchMode=Global
Use=false

Anyway, to avoid hijacking this bug, it was about a crash in system settings which still happens reproducibly for me. I'd guess removing a description for a layout in evdev.xml might be the cause, but I'll leave you to decide whether its worth tracking down (i.e. bad config shouldn't cause seg-faults in my opinion, at least in a perfect world).
Comment 7 Diggory Hardy 2013-02-01 12:11:21 UTC
Well, the story gets more interesting after adding descriptions to evdev.xml.

After logging out and in again, opening the settings and selecting configure, then trying to change the variant of one of the two layouts listed causes a crash. If instead of changing the layouts listed I remove those two and re-add my layout, it doesn't crash, but it still doesn't work properly (names of many of the variants are blank and if selected result in the default variant being used in kxkbrc). I can't work out why, other than noting that these variant names are the unique ones (not used in other layouts) and contain underscores (but I see names in other layouts using underscores).
Comment 8 Andriy Rysin 2013-02-01 16:06:41 UTC
Diggory, could you please attach your evdev.xml and layou file? also kxkbrc after you configure layouts in kde?
Comment 9 Diggory Hardy 2013-02-01 18:04:29 UTC
kxkbrc (after setting three layouts, for the last of which a variant other than default was selected):

[Layout]
DisplayNames=,cyb,cyb
LayoutList=us(colemak),cyborg16(colemak),cyborg16
LayoutLoopCount=-1
Model=thinkpad60
ResetOldOptions=false
ShowFlag=false
ShowLabel=true
ShowLayoutIndicator=true
ShowSingle=false
SwitchMode=Global
Use=true

The rest can be found at https://github.com/dhardy/keyboard (specifically the layout is in file cyborg16 and the contents of evdev-extension* files were merged with the xkb/rules/evdev.* files, as the last elements/lines of the respective sections of these files).
Comment 10 Andriy Rysin 2013-02-02 03:23:51 UTC
Diggory, all your variant items in evdev.xml expect one (US colemak) miss <configItem>, that's why they are all empty. If their names are empty that can easily lead to crash. I guess parsing code could be a bit more   robust (and it would be if rules xml used attributes instead of nested elements for everything) but currently this is file with wrong elements in it.
Please add <configItem> to all variants like in other layouts and let me know if it looks better.
Comment 11 Diggory Hardy 2013-02-02 13:00:40 UTC
Oh how embarrassing! Thank you, works perfectly now.

Hmm, if anything I prefer embedded elements for their extensibility, but having to choose and compromise on brevity is the real XML nuisance. Anyway, no point worrying about it.
Comment 12 Andriy Rysin 2013-02-07 03:44:59 UTC
Git commit 1b5f4652634710fce5fc6f4d59043f6e165bb023 by Andriy Rysin.
Committed on 07/02/2013 at 03:54.
Pushed by rysin into branch 'KDE/4.10'.

Remove layouts and variants with empty content

M  +14   -0    kcontrol/keyboard/tests/xkb_rules_test.cpp
M  +12   -13   kcontrol/keyboard/xkb_rules.cpp

http://commits.kde.org/kde-workspace/1b5f4652634710fce5fc6f4d59043f6e165bb023
Comment 13 Andriy Rysin 2013-02-07 03:47:22 UTC
I've pushed a fix to remove empty layouts/variants, hopefully this will prevent keyboard setting module from crashing.
Comment 14 Christoph Feck 2013-02-12 00:12:16 UTC
Andriy, did you reopen by accident?
Comment 15 Andriy Rysin 2013-02-13 12:47:09 UTC
oops, yes it should be fixed