NetBSD Problem Report #38148
From kre@munnari.OZ.AU Mon Mar 3 14:30:57 2008
Return-Path: <kre@munnari.OZ.AU>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id 3250163B90D
for <gnats-bugs@gnats.NetBSD.org>; Mon, 3 Mar 2008 14:30:57 +0000 (UTC)
Message-Id: <200803031429.m23ETO0B009311@jade.coe.psu.ac.th>
Date: Mon, 3 Mar 2008 21:29:24 +0700 (ICT)
From: kre@munnari.OZ.AU
To: gnats-bugs@gnats.NetBSD.org
Subject: sysutils/xbatt dumps core (sometimes) (+FIX)
X-Send-Pr-Version: 3.95
>Number: 38148
>Category: pkg
>Synopsis: sysutils/xbatt dumps core (sometimes) (+FIX)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: hubertf
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Mar 03 14:35:00 +0000 2008
>Closed-Date: Thu Mar 06 17:25:11 +0000 2008
>Last-Modified: Thu Mar 06 17:35:00 +0000 2008
>Originator: Robert Elz
>Release: NetBSD 4.99.42 (pkgsrc current wthin past 6 hours)
>Organization:
Prince of Songkla University
>Environment:
NetBSD epsilon.noi.kre.to 4.99.42 NetBSD 4.99.42 (EPSILON) #1: Mon Dec 24 00:29:14 ICT 2007 kre@epsilon.noi.kre.to:/home/kre/src/co/src/sys/arch/i386/compile/EPSILON i386
Architecture: i386
Machine: i386
>Description:
If the ACPI/APM subsystem reports a battery as > 100% full
(yes, weird, wheher that's a bug somewhere else is for
whoever understands this stuff to work out) then xbatt will
dump core when it receives focus (that is, when it attempts
to display the percentage full for the battery in words/digits
rather than via the "height of the green bar" graphics).
That's because it assumes that the remaining capacity / 10
is going to produce a value in the range 0..9 (that is, the
remaining capacity is < 100%). It deals with the case of
exactly 100% separately.
The fix is to simply treat everything >= 100% as "full" rather
that only exactly == 100%.
This should be fixed in xbatt, regardless of whether someone
decides that reporting >100% full is a bug somewhere else,
and that bug eventually gets fixed.
>How-To-Repeat:
This is probably not easy for most people to reproduce.
But start with a system where envstat reports something like...
(for me, this is a Dell Precision (XPS) M4300)
[acpiacad0]
connected: ON
[acpibat0]
present: ON
design cap: 7.800 Ah
last full cap: 7.583 Ah
technology: 1
design voltage: 11.100 V
warn cap: 0.780 Ah (10.29%)
low cap: 0.236 Ah ( 3.11%)
voltage: 12.921 V
charge rate: N/A
discharge rate: N/A
charge: 7.800 Ah (102.86%)
charging: OFF
charge state: NORMAL
[acpibat1]
present: OFF
design cap: 0.000 Wh
last full cap: 0.000 Wh
technology: 0
design voltage: 0.000 V
warn cap: 0.000 Wh
low cap: 0.000 Wh
voltage: 0.000 V
charge rate: 0.000 W
discharge rate: 0.000 W
charge: 0.000 Wh
charging: OFF
charge state: UNKNOWN
[acpitz0]
temperature: 60.500 degC
[coretemp0]
cpu0 temperature: 58.000 degC
[coretemp1]
cpu1 temperature: 61.000 degC
Then run xbatt, and move the mouse pointer into the
xbatt window (or take whatever steps your window manager
requires in order for xbatt to take notice, maybe a click
for some).
Expect to see a core dump (SEGV), in memcpy() called from
deep inside the X11 libraries.
>Fix:
Replace sysutils/xbatt/patches/patch-ab with the following patch.
This includes the original patch-ab, and the extra (one character)
change that fixes this problem.
Of course, regenerate the distinfo file checksums, and
do a revbump in the Makefile.
I have verified that this works in my environment (ie:
if this patch or something else like it is installed,
please don't bother with feedback state, just close the PR...)
And lastly, no, I haven't reported this to the xbatt authors
(if any such remain interested) - whoever is taking care of
doing that for the existing patch-ab changes can just add this
one to the list of things to inform them about!
$NetBSD: patch-ab,v 1.2 2001/11/26 20:02:36 wiz Exp $
--- xbatt.c.orig Fri Sep 18 14:03:05 1998
+++ xbatt.c
@@ -219,6 +219,7 @@
String fallback_resouces[] = {
"*width: 39",
"*height: 39",
+ NULL
};
main(
@@ -494,6 +495,7 @@
#ifdef __NetBSD__
struct apm_power_info info;
+ memset(&info, 0, sizeof(info));
if( ioctl(apmfd, APM_IOC_GETPOWER, &info) == -1 ) {
fprintf(stderr, "xbatt: ioctl APM_IOC_GETPOWER failed\n");
exit(1);
@@ -686,7 +688,7 @@
5, 5, 11, 7);
}
- if (s.remain == 100) {
+ if (s.remain >= 100) {
bm = XCreatePixmapFromBitmapData(XtDisplay(toplevel),
XtWindow(toplevel),
full_bits, full_width,
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: pkg-manager->hubertf
Responsible-Changed-By: obache@NetBSD.org
Responsible-Changed-When: Tue, 04 Mar 2008 01:29:22 +0000
Responsible-Changed-Why:
Over to maintainer.
State-Changed-From-To: open->closed
State-Changed-By: hubertf@NetBSD.org
State-Changed-When: Thu, 06 Mar 2008 17:25:11 +0000
State-Changed-Why:
commmitted, thanks!
- Hubert
From: Hubert Feyrer <hubertf@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/38148 CVS commit: pkgsrc/sysutils/xbatt
Date: Thu, 6 Mar 2008 17:24:23 +0000 (UTC)
Module Name: pkgsrc
Committed By: hubertf
Date: Thu Mar 6 17:24:23 UTC 2008
Modified Files:
pkgsrc/sysutils/xbatt: Makefile distinfo
pkgsrc/sysutils/xbatt/patches: patch-ab
Log Message:
Keep xbattbar from dumping core when the battery reports
>100% full. Patch submitted by kre@munnari.OZ.AU in PR 38148.
To generate a diff of this commit:
cvs rdiff -r1.23 -r1.24 pkgsrc/sysutils/xbatt/Makefile
cvs rdiff -r1.4 -r1.5 pkgsrc/sysutils/xbatt/distinfo
cvs rdiff -r1.2 -r1.3 pkgsrc/sysutils/xbatt/patches/patch-ab
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.