! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
xfpm panel plugin crashes at startup when the locale is not UTF8
Status:
RESOLVED: FIXED
Product:
Xfce4-power-manager
Component:
General

Comments

Description Landry Breuil editbugs 2014-08-23 11:07:24 CEST
On my desktop without battery/ac devices reported by upower, the panel plugin crashes at startup with the following trace:

(gdb) bt
#0  0x00001a0fcdedb930 in g_markup_escape_text () from /usr/local/lib/libglib-2.0.so.4000.0
#1  0x00001a0fd6e39c1b in gtk_widget_set_property () from /usr/local/lib/libgtk-x11-2.0.so.2400.0
#2  0x00001a10575289b6 in g_object_set_valist () from /usr/local/lib/libgobject-2.0.so.4000.0
#3  0x00001a1057528cda in g_object_set () from /usr/local/lib/libgobject-2.0.so.4000.0
#4  0x00001a10212bce1d in power_manager_button_show () from /usr/local/lib/xfce4/panel/plugins/libxfce4powermanager.so
#5  0x00001a10212bbb2d in xfce_panel_module_realize () from /usr/local/lib/xfce4/panel/plugins/libxfce4powermanager.so
#6  0x00001a1057520423 in g_closure_invoke () from /usr/local/lib/libgobject-2.0.so.4000.0
#7  0x00001a105753702d in signal_emit_unlocked_R () from /usr/local/lib/libgobject-2.0.so.4000.0
#8  0x00001a105753900d in g_signal_emit_valist () from /usr/local/lib/libgobject-2.0.so.4000.0
#9  0x00001a10575397a1 in g_signal_emit () from /usr/local/lib/libgobject-2.0.so.4000.0
#10 0x00001a0fd6e34ca7 in gtk_widget_realize () from /usr/local/lib/libgtk-x11-2.0.so.2400.0
#11 0x00001a0fd6e354c8 in gtk_widget_map () from /usr/local/lib/libgtk-x11-2.0.so.2400.0
#12 0x00001a105752019d in _g_closure_invoke_va () from /usr/local/lib/libgobject-2.0.so.4000.0
#13 0x00001a105753859f in g_signal_emit_valist () from /usr/local/lib/libgobject-2.0.so.4000.0
#14 0x00001a10575397a1 in g_signal_emit () from /usr/local/lib/libgobject-2.0.so.4000.0
#15 0x00001a0fd6e35be6 in gtk_widget_show () from /usr/local/lib/libgtk-x11-2.0.so.2400.0
#16 0x00001a0d70e03e86 in main () from /usr/local/lib/xfce4/panel/wrapper-1.0

will rebuild with debug symbols for more info.
Comment 1 Landry Breuil editbugs 2014-08-23 11:14:38 CEST
with debug syms, the crash comes from

#4  0x000002680e7b0fcd in power_manager_button_show (button=0x267cffc60b0) at ../power-manager-button.c:731
#5  0x000002680e7afc2d in xfce_panel_module_realize (xpp=0x26869d59130) at xfce-power-manager-plugin.c:75
Comment 2 Landry Breuil editbugs 2014-08-23 11:39:17 CEST
Seems the crash is caused by display_device being reported NULL in power_manager_button_set_tooltip().
Comment 3 Landry Breuil editbugs 2014-08-23 11:45:40 CEST
eric, did you test the panel plugin without batteries reported by upower ? i cant make any sense of this failure, since there's a fallback codepath in set_tooltip for the case where display_device is null..
Comment 4 Eric Koegel editbugs 2014-08-23 20:32:11 CEST
Yes... and I want to automate some of that with Jenkins in the future.

What version of xfpm and UPower are you using? Is your system 32bit? I'm just looking for how to reproduce this easily.

http://i.imgur.com/bYlUs2s.png That's the power manager plugin running on OpenBSD without any devices reported by UPower.
Comment 5 Landry Breuil editbugs 2014-08-24 09:16:43 CEST
xfpm 1.3.2, upower 0.99.0, OpenBSD/amd64. Havent tested i386 yet, but will soon, since i have an amd64 and an i386 laptop where xfpm will be more useful rather than on this desktop...

 $upower -d
Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         no
  updated:              Thu Jan  1 01:00:00 1970 (1408864470 seconds ago)
  has history:          no
  has statistics:       no
  unknown
    warning-level:       none
    icon-name:          ''

Daemon:
  daemon-version:  0.99.0
  on-battery:      no
  lid-is-closed:   no
  lid-is-present:  no
  is-docked:       no
  critical-action: PowerOff

(note that i'm also the upower maintainer in OpenBSD, and i wrote the backend inside upower, so if stuff need fixing/updating in upower itself i can have a look at it...)
Comment 6 Eric Koegel editbugs 2014-08-25 16:13:01 CEST
Created attachment 5612 
Prevent a crash on desktop systems

I'm pretty sure it's a bug in xfpm. If it's just the tooltip that breaks it, we can remove the tooltip. It's not like it's really useful for desktop systems anyway. Let me know if this patch fixes it.
Comment 7 Landry Breuil editbugs 2014-08-25 22:25:06 CEST
Comment on attachment 5612 
Prevent a crash on desktop systems

Yeah, the plugin doesnt crash with that line removed, and the button menu only has 'presentation mode' entry, the tooltip on the button is 'Computer', but i'd rather have the root cause of the bug fixed instead of shoving stuff under the carpet like this :)
Comment 8 Eric Koegel editbugs 2014-08-26 19:21:05 CEST
Created attachment 5613 
Try to pinpoint where it crashes

Me too. Can you try this patch with PANEL_DEBUG=1 xfce4-panel ? I'd like to see where we broke it. Thanks!
Comment 9 Eric Koegel editbugs 2014-08-26 19:42:19 CEST
oh and built with ./autogen.sh --enable-debug=yes (full probably won't work because of the g value array stuff).
Comment 10 Landry Breuil editbugs 2014-08-26 20:26:22 CEST
xfce4-panel-Message: Plugin power-manager-plugin-9 has been automatically restarted after crash.
xfce4-panel(external): power-manager-plugin-9: scheduled a respawn of the child
xfce4-panel(external): power-manager-plugin-9: child is unembedded
xfce4-panel(external): power-manager-plugin-9: child spawned; pid=7818, argc=8
xfce4-panel(external): power-manager-plugin-9: child is embedded; 5 properties in queue

** (wrapper-1.0:12222): WARNING **: No outputs have backlight property

** (xfpm-power-backlight-helper:10490): WARNING **: failed to find any devices: Erreur ? l'ouverture du r?pertoire ??/sys/class/backlight???: (null)

DBG[../power-manager-button.c:197] power_manager_button_set_tooltip(): setting generic tooltip
DBG[../power-manager-button.c:197] power_manager_button_set_tooltip(): setting generic tooltip
xfce4-panel(external): power-manager-plugin-9: child is unembedded
xfce4-panel(external): power-manager-plugin-9: child exited with status 139


and then there's the crash dialog..
Comment 11 Eric Koegel editbugs 2014-08-31 20:27:03 CEST
Created attachment 5620 
plugin: Fix crash when devices (dis)connect

Hey, haven't forgotten about this bug. I may not be able to reproduce it because I don't have an actual desktop to test with. I built another OpenBSD VM with UPower from git but it naturally wouldn't crash for me. However, I did find a way to make it crash (and that lead to a couple more corner cases). Anyway, can you try this patch out please?

If it does still crash can you provide the backtrace from PANEL_DBG=gdb xfce4-panel with the patch? Maybe it will crash somewhere new.
Comment 12 Landry Breuil editbugs 2014-09-01 21:36:59 CEST
WIth that patch, it seems it doesnt crash anymore, and the output is:

DBG[../power-manager-button.c:653] set_brightness_min_level(): button->priv->brightness_min_level : 0
DBG[../power-manager-button.c:384] power_manager_button_update_device_icon_and_details(): this is the display device, updating
DBG[../power-manager-button.c:825] power_manager_button_set_icon(): icon_width 24
DBG[../power-manager-button.c:825] power_manager_button_set_icon(): icon_width 26
DBG[../power-manager-button.c:1019] power_manager_button_menu_add_device(): filtering device from menu (display or line power device)
DBG[../power-manager-button.c:1019] power_manager_button_menu_add_device(): filtering device from menu (display or line power device)

So, that's an improvement.
The menu shows 'power manager settings' but nothing happens when i click on that item, and the last line in the debug log is added each time i try to click on it.
Comment 13 Landry Breuil editbugs 2014-09-01 21:41:03 CEST
oh sorry, disregard the last part of the previous comment, the xfpm settings dialog is correctly displayed when i click on the item, it was an issue on my side (had removed the package for xfpm, was just running the panel plugin from my git checkout .libs directory.
Comment 14 Eric Koegel editbugs 2014-09-02 02:52:48 CEST
Awesome, thanks for testing all these patches. Pushed to master:

commit 2e0de98b0b4322b92096554e3248a15771b3f9e3
Author: Eric Koegel <eric.koegel@gmail.com>
Date:   Sun Aug 31 21:11:56 2014 +0300

    plugin: Fix crash when devices (dis)connect
    
    There are a couple conditions where the plguin would crash or
    emit runtime warnings due a device being connected or
    disconnected. Those should be fixed now.
http://git.xfce.org/xfce/xfce4-power-manager/commit/?id=2e0de98b0b4322b92096554e3248a15771b3f9e3
Comment 15 Landry Breuil editbugs 2014-12-20 11:20:44 CET
Grr... i'm sorry, but right now with 1.4.2 the same failure is back...
Comment 16 Landry Breuil editbugs 2014-12-20 11:23:47 CET
Backtrace still the same as in comment 0, and on stderr:

** (xfpm-power-backlight-helper:14579): WARNING **: failed to find any devices: Erreur ? l'ouverture du r?pertoire ??/sys/class/backlight???: No such file or directory
DBG[../power-manager-button.c:651] set_brightness_min_level(): button->priv->brightness_min_level : 0
xfce4-panel-Message: Plugin power-manager-plugin-10 has been automatically restarted after crash.

Wonder if this has to do with the fact that brightness handling is expected to be present?
Comment 17 Landry Breuil editbugs 2014-12-20 11:55:46 CET
Note that it also crashes on a laptop with a battery reported by upower.
Comment 18 Olivier Duchateau 2014-12-20 16:40:57 CET
(In reply to Landry Breuil from comment #16)
> Backtrace still the same as in comment 0, and on stderr:
> 
> ** (xfpm-power-backlight-helper:14579): WARNING **: failed to find any
> devices: Erreur ? l'ouverture du r?pertoire ??/sys/class/backlight???: No
> such file or directory
> DBG[../power-manager-button.c:651] set_brightness_min_level():
> button->priv->brightness_min_level : 0
> xfce4-panel-Message: Plugin power-manager-plugin-10 has been automatically
> restarted after crash.
> 
> Wonder if this has to do with the fact that brightness handling is expected
> to be present?

I've same problem under FreeBSD. I use my own backend [1] (based on sysctl instead sysfs).

Tested on laptop without battery and acpi_video(4) not well supported.

[1] https://subversion.assembla.com/svn/xfce4/trunk/sysutils/xfce4-power-manager/files/
Comment 19 Landry Breuil editbugs 2014-12-21 21:22:52 CET
I'm not sure this is related to the crash i'm seeing, but xfpm should gracefully fallback if there's no support for backlight..

Do you plan to push back you backlight patch for freebsd ? Too bad upower itself only seems to support kbd backlight and not the actual screen brightness...
Comment 20 Landry Breuil editbugs 2015-03-01 22:39:08 CET
Okay. I finally decided to tackle that issue, and as usual .. that's because my env is *not* in UTF-8. I have LC_CTYPE/LC_MESSAGES set to fr_FR.ISO8859-15, and the issue is caused by a missing call to

xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");

in the panel plugin initialization, say power_manager_plugin_new() or power_manager_plugin_construct(). This line is in xfpm and xfpm-settings, but not the plugin.. adding this missing line on top of 1.4.3 produces a working panel plugin with french localization, properly showing battery device and brightness control. finally. Phew.

Do you want me to append a git-format-patch or ... ?
Comment 21 Eric Koegel editbugs 2015-03-02 05:31:15 CET
Sure! Unless you to push it yourself. I would have never guessed the text domain thing... Nice find.
Comment 22 Olivier Duchateau 2015-03-02 06:45:00 CET
Created attachment 6026 
Fix panel crashes when locale is not UTF-8

I use this patch, and everything is fine. Thanks Landry.
Comment 23 Eric Koegel editbugs 2015-03-02 08:33:41 CET
Thanks Landry and Olivier! Pushed to master in:
commit 7e3be2a03b4d4b950b31554bb93ce0cebf29475e
Author: Olivier Duchateau <duchateau.olivier@gmail.com>
Date:   Mon Mar 2 06:41:31 2015 +0000

    Fix xfpm panel plugin crashes at startup when the locale is not UTF8
    
    Signed-off-by: Eric Koegel <eric.koegel@gmail.com>
http://git.xfce.org/xfce/xfce4-power-manager/commit/?id=7e3be2a03b4d4b950b31554bb93ce0cebf29475e

Bug #11101

Reported by:
Landry Breuil
Reported on: 2014-08-23
Last modified on: 2015-03-02

People

Assignee:
Eric Koegel
CC List:
2 users

Version

Attachments

Additional information