Skip site navigation (1)Skip section navigation (2)
Date:      Mon,  9 Jul 2007 15:05:57 +0300 (EEST)
From:      Nikos Ntarmos <ntarmos@ceid.upatras.gr>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/114437: [patch] sysutils/conky dumps core with less than 10 processes in top
Message-ID:  <20070709120557.3685D3F40B@ace.b020.ceid.upatras.gr>
Resent-Message-ID: <200707091210.l69CADJe053167@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         114437
>Category:       ports
>Synopsis:       [patch] sysutils/conky dumps core with less than 10 processes in top
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 09 12:10:13 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Nikos Ntarmos
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
NetCInS Lab., C.E.I.D., U. of Patras, Greece
>Environment:
System: FreeBSD ace.b020.ceid.upatras.gr 7.0-CURRENT FreeBSD 7.0-CURRENT #3: Sun Jul 8 19:13:50 EEST 2007 ntarmos@ace.b020.ceid.upatras.gr:/opt/obj/opt/src/sys/ACE i386


	
>Description:
src/freebsd.c:proc_find_top() incorrectly assumes that at each point
there are at least 10 processes running. This may easily be false if
security.bsd.see_other_uids=0 and/or conky is launched early enough in
the xsession script.

	
>How-To-Repeat:
Set security.bsd.see_other_uids=0 and launch conky early in the xsession
script (or with less than 9 other processes running).
	
>Fix:

	

--- patch-src-freebsd.c-nprocsmax begins here ---
diff -u src/freebsd.c.orig src/freebsd.c
--- src/freebsd.c.orig	2007-07-09 13:13:14.000000000 +0300
+++ src/freebsd.c	2007-07-07 01:31:17.000000000 +0300
@@ -714,6 +714,7 @@
 	int n_processes;
 	int i, j = 0;
 	struct process *processes;
+	int nprocsmax;
 
 	int total_pages;
 
@@ -738,8 +739,10 @@
 		}
 	}
 
+	nprocsmax = (j > 10 ? 10 : j);
+
 	qsort(processes, j - 1, sizeof (struct process), comparemem);
-	for (i = 0; i < 10; i++) {
+	for (i = 0; i < nprocsmax; i++) {
 		struct process *tmp, *ttmp;
 
 		tmp = malloc(sizeof (struct process));
@@ -757,7 +760,7 @@
 	}
 
 	qsort(processes, j - 1, sizeof (struct process), comparecpu);
-	for (i = 0; i < 10; i++) {
+	for (i = 0; i < nprocsmax; i++) {
 		struct process *tmp, *ttmp;
 
 		tmp = malloc(sizeof (struct process));
@@ -776,13 +779,13 @@
 
 #if defined(FREEBSD_DEBUG)
 	printf("=====\nmem\n");
-	for (i = 0; i < 10; i++) {
+	for (i = 0; i < nprocsmax; i++) {
 		printf("%d: %s(%d) %.2f\n", i, mem[i]->name,
 				mem[i]->pid, mem[i]->totalmem);
 	}
 #endif
 
-	for (i = 0; i < j; free(processes[i++].name));
+	for (i = 0; i < nprocsmax; free(processes[i++].name));
 	free(processes);
 }
 
--- patch-src-freebsd.c-nprocsmax ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070709120557.3685D3F40B>