Bug 217316

Summary: Solid crashes plasma-desktop (hal 0.5.14 incompatibility) [HalPower::brightness, Solid::Control::PowerManager::brightness]
Product: [Frameworks and Libraries] solid Reporter: Dominic Battre <dominic>
Component: powermanagement-daemonAssignee: Dario Freddi <drf>
Status: RESOLVED FIXED    
Severity: crash CC: andresbajotierra, blackr2d, christof.debaes, efraim.feinstein, Hugo.Mildenberger, kai.kasurinen, kdebugs, micmicsh, nweibley, out.there, reavertm, u75620712, zelegolas
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description Dominic Battre 2009-12-04 11:17:45 UTC
Version:            (using KDE 4.3.4)
Compiler:          gcc 4.4.2 
OS:                Linux
Installed from:    Gentoo Packages

HAL Crashes with the following backtrace:

Thread 1 (Thread 0xb468b930 (LWP 15537)):
[KCrash Handler]
#6  qNumVariantToHelper<double> (this=0x0, ok=0x0) at kernel/qvariant.cpp:2361
#7  QVariant::toDouble (this=0x0, ok=0x0) at kernel/qvariant.cpp:2475
#8  0xa8f832ca in HalPower::brightness (this=0x8678918, device=...) at /var/tmp/portage/kde-base/solid-4.3.4/work/solid-4.3.4/solid/hal/halpower.cpp:396
#9  0xa928ef26 in Solid::Control::PowerManager::brightness (device=...) at /var/tmp/portage/kde-base/solid-4.3.4/work/solid-4.3.4/libs/solid/control/powermanager.cpp:198
#10 0xa903f155 in ?? () from /usr/lib/kde4/plasma_applet_battery.so
#11 0xbfd5e07c in ?? ()
#12 0x00000000 in ?? ()

Steps to reproduce:

Start KDE with battery plasmoid in panel on Thinkpad T60p. The crash happens immediately. Alternatively start plasma-desktop.

My environment is:
Thinkpad T60p, Gentoo, Kernel 2.6.32-gentoo (sys-kernel/gentoo-sources-2.6.32), sys-apps/hal-0.5.14, qt 4.6

Quick analysis:

This is the source from halpower.cpp

    if(m_halManager.call("FindDeviceByCapability", "keyboard_backlight").arguments().at(0).toStringList().contains(device))
    {
        QDBusInterface deviceInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device.KeyboardBacklight", QDBusConnection::systemBus()); //TODO - I do not have a backlight enabled keyboard, so I'm guessing a bit here. Could someone please check this.
        brightness = deviceInterface.call("GetBrightness").arguments().at(0).toDouble();
        if(deviceInterface.lastError().isValid())
        {
            return 0;
        }
        else
        {
            QDBusInterface propertyInterface("org.freedesktop.Hal", device, "org.freedesktop.Hal.Device", QDBusConnection::systemBus());
            int levels = propertyInterface.call("GetProperty", "keyboard_backlight.num_levels").arguments().at(0).toInt();
            return (float)(100*(brightness/(levels-1)));
        }
    }
    return 0;


The line after the comment "TODO - ..." is the one that crashes because at(0) returns 0.

This is what HAL tells me on the console.

~ > hal-find-by-capability --capability keyboard_backlight
/org/freedesktop/Hal/devices/leds_tpacpi_thinkvantage
/org/freedesktop/Hal/devices/leds_tpacpi_thinklight
/org/freedesktop/Hal/devices/leds_tpacpi_standby
/org/freedesktop/Hal/devices/leds_tpacpi_power

~ > hal-device
[...]
24: udi = '/org/freedesktop/Hal/devices/leds_tpacpi_thinkvantage'
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'leds'  (string)
  info.capabilities = { 'leds', 'keyboard_backlight' } (string list)
  info.category = 'leds'  (string)
  info.interfaces = { 'org.freedesktop.Hal.Device.Leds' } (string list)
  info.subsystem = 'leds'  (string)
  linux.sysfs_path = '/sys/devices/platform/thinkpad_acpi/leds/tpacpi::thinkvantage'  (string)
  info.parent = '/org/freedesktop/Hal/devices/platform_thinkpad_acpi'  (string)
  leds.device_name = 'tpacpi'  (string)
  keyboard_backlight.num_levels = 256  (0x100)  (int)
  leds.num_levels = 256  (0x100)  (int)
  leds.function = 'thinkvantage'  (string)
  info.udi = '/org/freedesktop/Hal/devices/leds_tpacpi_thinkvantage'  (string)
  info.addons.singleton = { 'hald-addon-leds' } (string list)

25: udi = '/org/freedesktop/Hal/devices/leds_tpacpi_thinklight'
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'leds'  (string)
  info.capabilities = { 'leds', 'keyboard_backlight' } (string list)
  info.category = 'leds'  (string)
  info.interfaces = { 'org.freedesktop.Hal.Device.Leds' } (string list)
  info.subsystem = 'leds'  (string)
  linux.sysfs_path = '/sys/devices/platform/thinkpad_acpi/leds/tpacpi::thinklight'  (string)
  info.parent = '/org/freedesktop/Hal/devices/platform_thinkpad_acpi'  (string)
  leds.device_name = 'tpacpi'  (string)
  keyboard_backlight.num_levels = 256  (0x100)  (int)
  leds.num_levels = 256  (0x100)  (int)
  leds.function = 'thinklight'  (string)
  info.udi = '/org/freedesktop/Hal/devices/leds_tpacpi_thinklight'  (string)
  info.addons.singleton = { 'hald-addon-leds' } (string list)

26: udi = '/org/freedesktop/Hal/devices/leds_tpacpi_standby'
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'leds'  (string)
  info.capabilities = { 'leds', 'keyboard_backlight' } (string list)
  info.category = 'leds'  (string)
  info.interfaces = { 'org.freedesktop.Hal.Device.Leds' } (string list)
  info.subsystem = 'leds'  (string)
  linux.sysfs_path = '/sys/devices/platform/thinkpad_acpi/leds/tpacpi::standby'  (string)
  info.parent = '/org/freedesktop/Hal/devices/platform_thinkpad_acpi'  (string)
  leds.device_name = 'tpacpi'  (string)
  keyboard_backlight.num_levels = 256  (0x100)  (int)
  leds.num_levels = 256  (0x100)  (int)
  leds.function = 'standby'  (string)
  info.udi = '/org/freedesktop/Hal/devices/leds_tpacpi_standby'  (string)
  info.addons.singleton = { 'hald-addon-leds' } (string list)

27: udi = '/org/freedesktop/Hal/devices/leds_tpacpi_power'
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'leds'  (string)
  info.capabilities = { 'leds', 'keyboard_backlight' } (string list)
  info.category = 'leds'  (string)
  info.interfaces = { 'org.freedesktop.Hal.Device.Leds' } (string list)
  info.subsystem = 'leds'  (string)
  linux.sysfs_path = '/sys/devices/platform/thinkpad_acpi/leds/tpacpi::power'  (string)
  info.parent = '/org/freedesktop/Hal/devices/platform_thinkpad_acpi'  (string)
  leds.device_name = 'tpacpi'  (string)
  keyboard_backlight.num_levels = 256  (0x100)  (int)
  leds.num_levels = 256  (0x100)  (int)
  leds.function = 'power'  (string)
  info.udi = '/org/freedesktop/Hal/devices/leds_tpacpi_power'  (string)
  info.addons.singleton = { 'hald-addon-leds' } (string list)
[...]

This might be related to bug #209582 which is closed already, however.
Comment 1 Dominic Battre 2009-12-04 11:28:59 UTC
I had one more idea...

The devices describes itself to implement org.freedesktop.Hal.Devices.Leds which is specified here
http://people.freedesktop.org/~dkukawka/hal-spec-git/hal-spec.html#interface-device-leds

Maybe it is a bug in Hal?
Comment 2 Dario Andres 2009-12-05 03:10:55 UTC
The fix for bug 209582 could also be related to your analysis. (I didn't read it all). Have you checked it http://websvn.kde.org/trunk/KDE/kdebase/workspace/solid/hal/halpower.cpp?r1=1057980&r2=1057979&pathrev=1057980 ?
Comment 3 Dario Andres 2009-12-05 17:21:36 UTC
The reporter of bug 217446 says that downgrading to HAL 0.5.13-r2 "fixes" this issue.
Comment 4 Dario Andres 2009-12-05 21:25:36 UTC
*** Bug 217425 has been marked as a duplicate of this bug. ***
Comment 5 Dario Andres 2009-12-05 21:25:39 UTC
*** Bug 217446 has been marked as a duplicate of this bug. ***
Comment 6 Jack 2009-12-06 01:23:56 UTC
I would remove "on Thinkpad T60p" from the description as I have the same results on completely different hardware - Dell XPS M2010.
Judging from my backtrace it's a rather fundamental incompatibility between solid 4.3.4 and hal 0.5.14 on brightness control so I would expect this to happen on other hardware configurations as well.
Comment 7 Christof Debaes 2009-12-06 06:45:05 UTC
I confirm the bug on Dell Latitude Hardware. The laptop has keyboard backlighting just like the Thinkpad T60p and the Dell XPS M2010. Downgrading to hal-0.5.13 worked.
Comment 8 Maciej Mrozowski 2009-12-06 19:05:49 UTC
See https://bugs.gentoo.org/295600 - there's some patch attached.
Comment 9 Dario Andres 2009-12-06 19:10:01 UTC
*** Bug 217617 has been marked as a duplicate of this bug. ***
Comment 10 felix 2009-12-06 20:09:42 UTC
Confirming for a DELL XPS m1330 on Kubuntu Lucid Lynx amd64. Downgrading to HAL 0.5.13 helped. ( I downloaded it from archive.ubuntu.com/ubuntu)

Thanks for the fast support concerning my duplicate.
Comment 11 Doug Semler 2009-12-11 16:22:45 UTC
Dell Inspiron 9600 - same problem.  

Right now it looks like hal 0.5.14 reports keyboard LEDs in the keyboard_backlight capabilities list.  On my Dell, keyboard_backlight capability list was previously empty (0.5.13 reports no devices as having keyboard_backlight capabilities). 

In addition, on my dell, I do have a device called .../Hal/devices/computer_backlight which reports capabilities "laptop_panel".  This works - I am able to use the Fn-<arrow> keys to set the brightness of the panel.
Comment 12 Nate Weibley 2009-12-12 15:58:14 UTC
Please note the SVN commits designed to fix this bug have caused the symptoms of bug 196232 to appear again (although the underlying cause is different).
Comment 13 Sebastian Kügler 2009-12-15 00:02:57 UTC
SVN commit 1062504 by sebas:

Fixes implicit typecast from previous commit to halpower.cpp and addresses a new bug precipitated by hal-0.5.14 in which the battery plasmoid unconditionally reset screen brightness to 0

Patch by Nate Weibley

CCMAIL:nweibley@gmail.com
BUG:196232
BUG:217316

 M  +1 -1      libs/solid/control/powermanager.cpp  
 M  +2 -2      solid/hal/halpower.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1062504
Comment 14 Dario Andres 2009-12-17 20:33:23 UTC
*** Bug 219095 has been marked as a duplicate of this bug. ***
Comment 15 Dario Andres 2009-12-19 22:59:37 UTC
*** Bug 219333 has been marked as a duplicate of this bug. ***
Comment 16 Dario Andres 2009-12-19 23:51:01 UTC
- Could you check if bug 219333 is the same ? Thanks
Comment 17 Dario Andres 2009-12-24 13:55:38 UTC
*** Bug 219919 has been marked as a duplicate of this bug. ***
Comment 18 Dario Andres 2009-12-26 01:28:06 UTC
*** Bug 220055 has been marked as a duplicate of this bug. ***
Comment 19 Jonathan Thomas 2009-12-29 15:03:25 UTC
*** Bug 220507 has been marked as a duplicate of this bug. ***
Comment 20 Dario Andres 2010-01-03 14:44:12 UTC
*** Bug 221058 has been marked as a duplicate of this bug. ***