Package: htop
Version: 0.8.3-1
Severity: normal
Tags: patch


htop shows negative cpu usage time:

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
 9785  user      20   0  325M  236M  1860 S  0.0  1.5  0:00.12 ./mprime
 9792  user      39  19  325M  236M  1860 R  0.0  1.5 -596523h-14:-8 ./mprime
 9796  user      39  19  325M  236M  1860 R  0.0  1.5 -596523h-14:-8 ./mprime
 9797  user      39  19  325M  236M  1860 R  0.0  1.5 -596523h-14:-8 ./mprime
 9798  user      39  19  325M  236M  1860 R  0.0  1.5 -596523h-14:-8 ./mprime
 9781  user      30  10  325M  236M  1860 S  0.0  1.5 -596523h-14:-8 ./mprime

This is caused by an integer overflow. The high number is comming from the 
Kernel: (e.g.)
 user@kvm:~$ cat /proc/9781/task/9798/stat
9798 (mprime) R 4413 9781 4413 34824 9781 4202560 46384 0 4 0 13739580949 
918902298809 0 0 39 19 6 0 46913565 341078016 60514 18446744073709551615 
4194304 29585884 140735277536320 139701526982104 17369198 0 0 0 16386 0 0 0 -1 
3 0 0 9183 0 0

918902298809 + 13739580949 is quite a large number (>2^31-1)

Int should actually be enough at that place.


>From 1f5d6f44731482f76262ee71179a1ded3a0bf737 Mon Sep 17 00:00:00 2001
From: Micha M. <mt...@web.de>
Date: Fri, 27 Jan 2012 22:00:43 +0100
Subject: [PATCH] Fix integer overflow

Without this fix I get something like:

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
 9785  user      20   0  325M  236M  1860 S  0.0  1.5  0:00.12 ./mprime
 9792  user      39  19  325M  236M  1860 R  0.0  1.5 -596523h-14:-8 ./mprime
 9796  user      39  19  325M  236M  1860 R  0.0  1.5 -596523h-14:-8 ./mprime
 9797  user      39  19  325M  236M  1860 R  0.0  1.5 -596523h-14:-8 ./mprime
 9798  user      39  19  325M  236M  1860 R  0.0  1.5 -596523h-14:-8 ./mprime
 9781  user      30  10  325M  236M  1860 S  0.0  1.5 -596523h-14:-8 ./mprime

After:

  PID USER     PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
 9781  user     30  10  325M  236M  1860 S  0.0  1.5  0:00.01 ./mprime
 9785  user     20   0  325M  236M  1860 S  0.0  1.5  0:00.12 ./mprime
 9792  user     39  19  325M  236M  1860 R  0.0  1.5 2590671h22:11 ./mprime
 9796  user     39  19  325M  236M  1860 R  0.0  1.5 2581130h26:17 ./mprime
 9797  user     39  19  325M  236M  1860 R  0.0  1.5 2562047h47:16 ./mprime
 9798  user     39  19  325M  236M  1860 R  0.0  1.5 2590671h53:17 ./mprime

It looks like that there is a bug in the Linux Kernel:

 user@kvm:~$ cat /proc/9781/task/9798/stat
9798 (mprime) R 4413 9781 4413 34824 9781 4202560 46384 0 4 0 13739580949 
918902298809 0 0 39 19 6 0 46913565 341078016 60514 18446744073709551615 
4194304 29585884 140735277536320 139701526982104 17369198 0 0 0 16386 0 0 0 -1 
3 0 0 9183 0 0
 user@kvm:~$ uname -a
Linux kvm 2.6.32-5-amd64 #1 SMP Thu Nov 3 03:41:26 UTC 2011 x86_64 GNU/Linux
 user@kvm:~$

Signed-off-by: Micha M. <mt...@web.de>
---
 Process.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Process.c b/Process.c
index 8f3762c..0cc990f 100644
--- a/Process.c
+++ b/Process.c
@@ -236,7 +236,7 @@ static void Process_printTime(RichString* str, unsigned 
long t) {
    double jiffytime = 1.0 / jiffy;
 
    double realTime = t * jiffytime;
-   int iRealTime = (int) realTime;
+   long long iRealTime = (long long) realTime;
 
    int hours = iRealTime / 3600;
    int minutes = (iRealTime / 60) % 60;
-- 
1.7.0.4




-- System Information:
Debian Release: 6.0.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages htop depends on:
ii  libc6                     2.11.2-10      Embedded GNU C Library: Shared lib
ii  libncurses5               5.7+20100313-5 shared libraries for terminal hand

htop recommends no packages.

Versions of packages htop suggests:
pn  ltrace                        <none>     (no description available)
pn  strace                        <none>     (no description available)

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to