Bug 105182 - ksysguard: localhost connection lost
Summary: ksysguard: localhost connection lost
Status: RESOLVED FIXED
Alias: None
Product: ksysguard
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KSysGuard Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-06 12:34 UTC by Giovanni Venturi
Modified: 2005-06-26 16:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
acpi.c.diff (3.64 KB, text/x-diff)
2005-05-25 22:36 UTC, Giovanni Venturi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Giovanni Venturi 2005-05-06 12:34:14 UTC
Version:           1.2.0 (using KDE 3.4.0, compiled sources)
Compiler:          gcc version 3.3.5
OS:                Linux (i686) release 2.6.10

I used ksysguard till KDE 3.3.x and I've got no problem on my Centrino Laptop with kernel 2.6.10, but now with KDE 3.4.x when I start up ksysguard to see the ProcessTable a window opens and say me: "localhost connection lost".
I see also the bug 53674 and this is not a duplicate because the #53674 bug was referead to KDE 2.2 in date 2003-01-30 and from KDE 2.2 to KDE 3.4 there was something like 2 years. With kernel 2.4.29 I haven't this bug, all works. And with my desktop PC with KDE 3.4 I haven't this bug.
The problem is with my Centrino laptop after KDE 3.4. At least into 3_4_BRANCH of about 2 weeks ago. I tryed to execute ksysguard from Konsole bug I get no output in line and the "nofork" option is not available for ksysguard.
Comment 1 Tobias Koenig 2005-05-06 15:16:26 UTC
On Fri, May 06, 2005 at 10:34:16AM -0000, Giovanni Venturi wrote:
> I used ksysguard till KDE 3.3.x and I've got no problem on my Centrino Laptop
> with kernel 2.6.10, but now with KDE 3.4.x when I start up ksysguard to see
> the ProcessTable a window opens and say me: "localhost connection lost".

What happens when you type
  ksysguardd
(pay attention to the double 'd') into a konsole window?

Ciao,
Tobias
Comment 2 Giovanni Venturi 2005-05-06 15:41:38 UTC
ksysguardd 1.2.0
(c) 1999, 2000, 2001, 2002 Chris Schlaeger <cs@kde.org> and
(c) 2001 Tobias Koenig <tokoe@kde.org>
This program is part of the KDE Project and licensed under
the GNU GPL version 2. See http://www.kde.org for details.
Segmentation fault

Ciao,
Giovanni
Comment 3 Tobias Koenig 2005-05-09 18:31:26 UTC
On Fri, May 06, 2005 at 01:41:40PM -0000, Giovanni Venturi wrote:
Hi,

> Segmentation fault

 ^^^ That's interesting...
Could you start the following command please:
  gdb ksysguardd
then type 'run' at the appearing prompt, wait until the segfault
appears and call 'bt' then?

Ciao,
Tobias
Comment 4 Giovanni Venturi 2005-05-10 10:32:14 UTC
gdb ksysguardd

GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...Using host libthread_db 
library "/lib/libthread_db.so.1".

(gdb) run
Starting program: /opt/kde34/bin/ksysguardd
ksysguardd 1.2.0
(c) 1999, 2000, 2001, 2002 Chris Schlaeger <cs@kde.org> and
(c) 2001 Tobias Koenig <tokoe@kde.org>
This program is part of the KDE Project and licensed under
the GNU GPL version 2. See http://www.kde.org for details.

Program received signal SIGSEGV, Segmentation fault.
0x4008c795 in strncpy () from /lib/libc.so.6
(gdb) bt
#0  0x4008c795 in strncpy () from /lib/libc.so.6
#1  0x080514c6 in initAcpi ()
#2  0x0804adf0 in initModules ()
#3  0x0804aea0 in main ()
(gdb)


Ciao,
Giovanni
Comment 5 Tobias Koenig 2005-05-10 16:31:26 UTC
On Tue, May 10, 2005 at 08:32:16AM -0000, Giovanni Venturi wrote:
Hi Giovanni,

> Program received signal SIGSEGV, Segmentation fault.
> 0x4008c795 in strncpy () from /lib/libc.so.6
> (gdb) bt
> #0  0x4008c795 in strncpy () from /lib/libc.so.6
> #1  0x080514c6 in initAcpi ()
> #2  0x0804adf0 in initModules ()
> #3  0x0804aea0 in main ()
> (gdb)

Hmm, what does the directory /proc/acpi/battery/ look like on your
system?

Ciao,
Tobias
Comment 6 Giovanni Venturi 2005-05-10 16:50:14 UTC
On my system:

ls -R /proc/acpi/battery/
/proc/acpi/battery/:
C11F

/proc/acpi/battery/C11F:
alarm  info  state


Ciao,
Giovanni
Comment 7 Tobias Koenig 2005-05-10 17:41:17 UTC
On Tue, May 10, 2005 at 02:50:18PM -0000, Giovanni Venturi wrote:
Hi Giovanni,

> ls -R /proc/acpi/battery/
> /proc/acpi/battery/:
> C11F

 ^^^ that looks really, really strange... which distribution/kernel do you use?

Ciao,
Tobias
Comment 8 Giovanni Venturi 2005-05-11 10:19:30 UTC
Hello Tobias,
>
> > ls -R /proc/acpi/battery/
> > /proc/acpi/battery/:
> > C11F
>
>  ^^^ that looks really, really strange... which distribution/kernel do you
> use?
>

I use Slackware-current, but I compile the kernel on my own and I use kernel 
vanilla. The problem is still there with 2.6.12-rc4, but now I use 2.6.10 
because alsa driver with the lastest kernel wants alsa-utils 1.0.9rc4 and I'm 
waiting the Slackware mantainer update that packets.
Ciao,
Giovanni
Comment 9 Giovanni Venturi 2005-05-24 10:13:20 UTC
Can be this bug fixed? Can I help you Tobias in some way?
Ciao,
Giovanni
Comment 10 Tobias Koenig 2005-05-24 12:55:59 UTC
Hi Giovanni,

the patch that should fix your problem was applyed
on Fri Apr 8 17:13:58 2005 UTC.

Could you test KDE from CVS HEAD?

Ciao,
Tobias


	
		
___________________________________________________________ 
Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
Comment 11 Giovanni Venturi 2005-05-24 13:23:08 UTC
Well, could be a problem. If you can tell me what changed I can change it into 
my local branch and try, so if all ok we can close this bug.
Ciao,
Giovanni
Comment 12 Tobias Koenig 2005-05-24 19:44:12 UTC
On Tue, May 24, 2005 at 11:23:09AM -0000, Giovanni Venturi wrote:
Hi Giovanni,

> Well, could be a problem. If you can tell me what changed I can change it into 
> my local branch and try, so if all ok we can close this bug.

See
 http://websvn.kde.org/trunk/kdebase/ksysguard/ksysguardd/Linux/acpi.c?rev=404102&r1=357909&r2=404102
for the change, you can ignore all the AcpiThermalZones stuff.

Ciao,
Tobias
Comment 13 Giovanni Venturi 2005-05-25 22:36:23 UTC
Well at the end I compiled HEAD :) and it works.
So I take a look at the link you send me and I produced the attached patch 
following your code (kdebase/ksysguard/ksysguardd/Linux/acpi.c). Look at 
that, compile it on your system I'm going to compile it on my Desktop system 
next days. For the laptop is ok, and also for the Desktop.
If it's ok for you too tell me. Or you or me can commit for kde 3.4.2 and 
close this bug.
Well, better if you do this because the fix is a your work.
Ciao,
Gianni


Created an attachment (id=11203)
acpi.c.diff
Comment 14 Giovanni Venturi 2005-06-06 10:28:20 UTC
The patch doesn't work for you?
Comment 15 Giovanni Venturi 2005-06-17 23:57:28 UTC
Tobias I'd like to see close this bug... I'd like to commit the patch for KDE 
3.4.2, but you are the manteiner and jsut you can say if I can or not commit.
Let me know,
Giovanni
Comment 16 Tobias Koenig 2005-06-22 21:01:53 UTC
On Fri, Jun 17, 2005 at 09:57:30PM -0000, Giovanni Venturi wrote:
> Tobias

Hi Giovanni,

> I'd like to see close this bug... I'd like to commit the patch for KDE 
> 3.4.2, but you are the manteiner and jsut you can say if I can or not commit.

I've currently no KDE 3.4 checked out for testing, so I'll just trust
you that the code works, please commit.

Ciao,
Tobias
Comment 17 Giovanni Venturi 2005-06-23 10:36:43 UTC
SVN commit 428125 by gianni:

This fix the bug #105182 with the merged code from the trunk by Tobias I hope no problem 

BUG:105182


 M  +41 -32    acpi.c   [POSSIBLY UNSAFE: scanf]


--- branches/KDE/3.4/kdebase/ksysguard/ksysguardd/Linux/acpi.c #428124:428125
@@ -1,6 +1,6 @@
 /*
     KSysGuard, the KDE System Guard
-    
+
     Copyright (c) 2003 Stephan Uhlmann <su@su2.info> 
 
     This program is free software; you can redistribute it and/or
@@ -35,7 +35,6 @@
 #define ACPIBATTERYINFOBUFSIZE 1024
 #define ACPIBATTERYSTATEBUFSIZE 512
 
-static int AcpiBatteryOK = 0;
 static int AcpiBatteryNum = 0;
 static char AcpiBatteryNames[ ACPIBATTERYNUMMAX ][ 8 ];
 static int AcpiBatteryCharge[ ACPIBATTERYNUMMAX ];
@@ -48,40 +47,52 @@
 
 void initAcpi( struct SensorModul* sm )
 {
-  int BatteryDirNummer;
+    initAcpiBattery(sm); 
+}
+
+int updateAcpi( void ) 
+{
+  if (AcpiBatteryNum > 0) {
+    updateAcpiBattery(); 
+  }
+
+  return 0;
+}
+
+void exitAcpi( void ) 
+{
+  AcpiBatteryNum = -1;
+}
+
+
+/************ ACPI Battery **********/
+
+void initAcpiBattery( struct SensorModul* sm )
+{
   DIR *d;
   struct dirent *de;
   char s[ ACPIFILENAMELENGTHMAX ];
 
   if ( ( d = opendir( "/proc/acpi/battery" ) ) == NULL ) {
-    print_error( "Directory \'/proc/acpi/battery\' does not exist or is not readable.\n"
-                 "Load the battery ACPI kernel module or compile it into your kernel.\n" );
-    AcpiBatteryOK = -1;
+    AcpiBatteryNum = -1;
     return;
   } else {
+    AcpiBatteryNum = 0;
     while ( ( de = readdir( d ) ) )
       if ( ( strcmp( de->d_name, "." ) != 0 ) && ( strcmp( de->d_name, ".." ) != 0 ) ) {
-        sscanf(de->d_name,"BAT%d",&BatteryDirNummer);
-        strncpy( AcpiBatteryNames[ BatteryDirNummer ], de->d_name, 8 );
-        snprintf( s, sizeof( s ), "acpi/battery/%d/batterycharge", AcpiBatteryNum );
-        registerMonitor( s, "integer", printAcpiBatFill, printAcpiBatFillInfo, sm );
-        snprintf( s, sizeof( s ), "acpi/battery/%d/batteryusage", AcpiBatteryNum );
-	registerMonitor( s, "integer", printAcpiBatUsage, printAcpiBatUsageInfo, sm);
-        AcpiBatteryCharge[ BatteryDirNummer ] = 0;
-        AcpiBatteryNum++;
+         strncpy( AcpiBatteryNames[ AcpiBatteryNum ], de->d_name, 8 );
+         snprintf( s, sizeof( s ), "acpi/battery/%d/batterycharge", AcpiBatteryNum );
+         registerMonitor( s, "integer", printAcpiBatFill, printAcpiBatFillInfo, sm );
+         snprintf( s, sizeof( s ), "acpi/battery/%d/batteryusage", AcpiBatteryNum );
+         registerMonitor( s, "integer", printAcpiBatUsage, printAcpiBatUsageInfo, sm);
+         AcpiBatteryCharge[ AcpiBatteryNum ] = 0;
+         AcpiBatteryNum++;
       }
-
-    AcpiBatteryOK = 1;
   }
 }
 
-void exitAcpi( void )
+int updateAcpiBattery( void )
 {
-  AcpiBatteryOK = -1;
-}
-
-int updateAcpi( void )
-{
   int i, fd;
   char s[ ACPIFILENAMELENGTHMAX ];
   size_t n;
@@ -90,8 +101,8 @@
   char *p;
   int AcpiBatCapacity = 1;
   int AcpiBatRemainingCapacity = 0;
-  
-  if ( AcpiBatteryOK < 0 )
+
+  if ( AcpiBatteryNum <= 0 )
     return -1;
 
   for ( i = 0; i < AcpiBatteryNum; i++ ) {
@@ -139,7 +150,7 @@
       if ( p )
         p++;
     }
-    
+
     /* get current battery usage, (current Current) */
     p = AcpiBatStateBuf;
     while ( ( p!= NULL ) && ( sscanf( p, "present rate: %d ",
@@ -147,18 +158,16 @@
       p = strchr( p, '\n' );
       if ( p )
         p++;
-    } 
-    
-    
+    }
+
+
     /* calculate charge rate */
     if ( AcpiBatCapacity > 0 )
       AcpiBatteryCharge[ i ] = AcpiBatRemainingCapacity * 100 / AcpiBatCapacity;
     else
       AcpiBatteryCharge[ i ] = 0;
-    
-    
 
-  } 
+  }
 
   return 0;
 }
@@ -182,7 +191,7 @@
 void printAcpiBatUsage( const char* cmd)
 {
  int i;
- 
+
  sscanf( cmd + 13, "%d", &i );
  fprintf(CurrentClient, "%d\n", AcpiBatteryUsage[ i ] );
 }
Comment 18 Mashrab Kuvatov 2005-06-26 12:55:34 UTC
Giovanni, please fix acpi.h too.
Comment 19 Giovanni Venturi 2005-06-26 16:22:38 UTC
SVN commit 429089 by gianni:

I forgot to change this
CCBUG: 105182


 M  +3 -0      acpi.h  


--- branches/KDE/3.4/kdebase/ksysguard/ksysguardd/Linux/acpi.h #429088:429089
@@ -24,7 +24,10 @@
 void exitAcpi( void );
 
 int updateAcpi( void );
+int updateAcpiBattery( void );
 
+void initAcpiBattery( struct SensorModul* sm );
+
 void printAcpiBatFill( const char* );
 void printAcpiBatFillInfo( const char* );
 void printAcpiBatUsage( const char* );