pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/38148: sysutils/xbatt dumps core (sometimes) (+FIX)



>Number:         38148
>Category:       pkg
>Synopsis:       sysutils/xbatt dumps core (sometimes) (+FIX)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 03 14: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@localhost:/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,

>Unformatted:
        
        


Home | Main Index | Thread Index | Old Index