Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/ps When converting from pages to kilobytes, cast the ret...
details: https://anonhg.NetBSD.org/src/rev/4e61ce559cd9
branches: trunk
changeset: 766008:4e61ce559cd9
user: dholland <dholland%NetBSD.org@localhost>
date: Mon Jun 13 03:42:15 2011 +0000
description:
When converting from pages to kilobytes, cast the return value of
getpagesize() to size_t. For some reason getpagesize() is defined to
return int, and several of the page counts we get come back from the
kernel as int32_t; in LP64 without the cast the byte count will be
computed in a 32-bit value and for large processes will overflow and
become negative... and then remain negative when divided by 1024 to
convert to kilobytes.
Fixes a problem I hit the other day where I saw negative RSS, which
turns out also to be PR 40642.
Note: other logic in here will break down when we first get >2TB
processes... and int32 page counts will break on >8TB processes. But
hopefully we won't see any of that for a few years yet.
diffstat:
bin/ps/print.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r f1618d5ba561 -r 4e61ce559cd9 bin/ps/print.c
--- a/bin/ps/print.c Mon Jun 13 03:23:53 2011 +0000
+++ b/bin/ps/print.c Mon Jun 13 03:42:15 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: print.c,v 1.117 2011/01/22 21:09:51 christos Exp $ */
+/* $NetBSD: print.c,v 1.118 2011/06/13 03:42:15 dholland Exp $ */
/*
* Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
#if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#else
-__RCSID("$NetBSD: print.c,v 1.117 2011/01/22 21:09:51 christos Exp $");
+__RCSID("$NetBSD: print.c,v 1.118 2011/06/13 03:42:15 dholland Exp $");
#endif
#endif /* not lint */
@@ -967,7 +967,7 @@
}
}
-#define pgtok(a) (((a)*getpagesize())/1024)
+#define pgtok(a) (((a)*(size_t)getpagesize())/1024)
void
vsize(void *arg, VARENT *ve, int mode)
Home |
Main Index |
Thread Index |
Old Index