Xymon Mailing List Archive search

overflow in netbsd-meminfo.c

list Rich Smrcina
Thu, 13 Nov 2008 05:25:05 -0600
Message-Id: <user-77e8c2ced801@xymon.invalid>

You posted this last night:

    Memory              Used       Total  Percentage
  Physical     4294963639M 4294966523M          0%
  Swap                  0M       4098M          0%

It appears that Hobbit is reading the 'physical' line, therefore causing the negative value in meminfo.  If you have 4G of memory on your machine, the value is clearly wrong, so the error is in netbsd.  Changing the Hobbit code isn't fixing the problem, it just makes the value more readable... :)  Hobbit will still reflect a wrong memory value.

Tracy Di Marco White wrote:
On Wed, Nov 12, 2008 at 10:43 PM, Rich Smrcina <user-cf452ff334e0@xymon.invalid> wrote:

It looks like the problem is this, then?
# sysctl -a|grep physmem
hw.physmem = -537526272
hw.physmem64 = 3757441024

But if hobbit is using a signed int, which it does seem to be here, I
don't see how hobbit could get it anything but wrong when there's more
than 2 GB of RAM.
Given this code, that's my understanding:
   25 	int physmem;
   67 	printf("Total:%d\n", (physmem / (1024 * 1024)));

So is this also a bug in FreeBSD, as they are also using an unsigned
long, for this and for pagesize?

Could you help me understand why you say this is a bug in NetBSD?

-Tracy

-- 
Rich Smrcina
VM Assist, Inc.
Phone: XXX-XXX-XXXX
Ans Service:  XXX-XXX-XXXX
http://www.linkedin.com/in/richsmrcina

Catch the WAVV!  http://www.wavv.org
WAVV 2009 - Orlando, FL - May 15-19, 2009