From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Problem report #131: base/src/emacs/src/process.c (procfs_system_process_attributes); UNINIT Date: Tue, 02 Dec 2008 17:17:35 -0800 Message-ID: <200812030120.mB31KVC4022814@mothra.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1228267786 2287 80.91.229.12 (3 Dec 2008 01:29:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Dec 2008 01:29:46 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 03 02:30:49 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L7gZd-0005E4-Ly for ged-emacs-devel@m.gmane.org; Wed, 03 Dec 2008 02:30:42 +0100 Original-Received: from localhost ([127.0.0.1]:56877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L7gYS-0000hy-WE for ged-emacs-devel@m.gmane.org; Tue, 02 Dec 2008 20:29:29 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L7gQ4-0003YD-Ro for emacs-devel@gnu.org; Tue, 02 Dec 2008 20:20:48 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L7gQ3-0003Wy-KK for emacs-devel@gnu.org; Tue, 02 Dec 2008 20:20:48 -0500 Original-Received: from [199.232.76.173] (port=53402 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L7gQ3-0003Wd-EH for emacs-devel@gnu.org; Tue, 02 Dec 2008 20:20:47 -0500 Original-Received: from barrelv2.ics.uci.edu ([128.195.1.114]:48813) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1L7gQ0-00009g-Qc for emacs-devel@gnu.org; Tue, 02 Dec 2008 20:20:45 -0500 Original-Received: from mothra.ics.uci.edu (mothra.ics.uci.edu [128.195.6.93]) by barrelv2.ics.uci.edu (8.13.7+Sun/8.13.7) with ESMTP id mB31KVcW018413 for ; Tue, 2 Dec 2008 17:20:36 -0800 (PST) Original-Received: (from dann@localhost) by mothra.ics.uci.edu (8.13.8+Sun/8.13.6/Submit) id mB31KVC4022814; Tue, 2 Dec 2008 17:20:31 -0800 (PST) Original-Lines: 284 X-ICS-MailScanner-Information: Please contact the ISP for more information X-ICS-MailScanner-ID: mB31KVcW018413 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (score=2.752, required 5, autolearn=disabled, ALL_TRUSTED -1.44, FF_IHOPE_YOU_SINK 1.70, FM_MULTI_ODD2 1.10, FM_MULTI_ODD3 0.70, TW_AJ 0.08, TW_CF 0.08, TW_CP 0.08, TW_GC 0.08, TW_JF 0.08, TW_OC 0.08, TW_PW 0.08, TW_TP 0.08, TW_WU 0.08) X-ICS-MailScanner-SpamScore: ss X-ICS-MailScanner-From: dann@mothra.ics.uci.edu X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:106479 Archived-At: CID: 131 Checker: UNINIT (help) File: base/src/emacs/src/process.c Function: procfs_system_process_attributes Description: Using uninitialized value "cmd" as argument to function "strncat" Event var_decl: Declared variable "cmd" without initializer Also see events: [uninit_arg] 7249 const char *cmd; 7250 char *cmdline = NULL; 7251 size_t cmdsize, cmdline_size; 7252 unsigned char c; 7253 int proc_id, ppid, uid, gid, pgrp, sess, tty, tpgid, thcount; 7254 unsigned long long utime, stime, cutime, cstime, start; 7255 long priority, nice, rss; 7256 unsigned long minflt, majflt, cminflt, cmajflt, vsize; 7257 time_t sec; 7258 unsigned usec; 7259 EMACS_TIME tnow, tstart, tboot, telapsed,ttotal; 7260 double pcpu, pmem; 7261 Lisp_Object attrs = Qnil; 7262 Lisp_Object cmd_str, decoded_cmd, tem; 7263 struct gcpro gcpro1, gcpro2; 7264 EMACS_INT uid_eint, gid_eint; 7265 7266 CHECK_NUMBER_OR_FLOAT (pid); 7267 proc_id = FLOATP (pid) ? XFLOAT_DATA (pid) : XINT (pid); 7268 sprintf (procfn, "/proc/%lu", proc_id); At conditional (1): "stat < 0" taking false path 7269 if (stat (procfn, &st) < 0) 7270 return attrs; 7271 7272 GCPRO2 (attrs, decoded_cmd); 7273 7274 /* euid egid */ 7275 uid = st.st_uid; 7276 /* Use of EMACS_INT stops GCC whining about limited range of data type. */ 7277 uid_eint = uid; At conditional (2): "uid_eint > 1152921504606846975" taking true path 7278 attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid_eint)), attrs); 7279 BLOCK_INPUT; 7280 pw = getpwuid (uid); At conditional (3): "interrupt_input_blocked == 0" taking true path At conditional (4): "interrupt_input_pending != 0" taking true path At conditional (5): "pending_atimers != 0" taking true path At conditional (6): "0" taking false path 7281 UNBLOCK_INPUT; At conditional (7): "pw != 0" taking true path 7282 if (pw) 7283 attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs); 7284 7285 gid = st.st_gid; 7286 gid_eint = gid; At conditional (8): "gid_eint > 1152921504606846975" taking true path 7287 attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid_eint)), attrs); 7288 BLOCK_INPUT; 7289 gr = getgrgid (gid); At conditional (9): "interrupt_input_blocked == 0" taking true path At conditional (10): "interrupt_input_pending != 0" taking true path At conditional (11): "pending_atimers != 0" taking true path At conditional (12): "0" taking false path 7290 UNBLOCK_INPUT; At conditional (13): "gr != 0" taking true path 7291 if (gr) 7292 attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); 7293 7294 strcpy (fn, procfn); 7295 procfn_end = fn + strlen (fn); 7296 strcpy (procfn_end, "/stat"); 7297 fd = emacs_open (fn, O_RDONLY, 0); At conditional (14): "fd >= 0" taking true path At conditional (15): "nread = emacs_read > 0" taking false path 7298 if (fd >= 0 && (nread = emacs_read (fd, procbuf, sizeof(procbuf) - 1)) > 0) 7299 { 7300 procbuf[nread] = '\0'; 7301 p = procbuf; 7302 7303 cmd = NULL; 7304 p = strchr (p, '('); 7305 if (p != NULL) 7306 { 7307 q = strrchr (p + 1, ')'); 7308 /* comm */ 7309 if (q != NULL) 7310 { 7311 cmd = p + 1; 7312 cmdsize = q - cmd; 7313 } 7314 } 7315 if (cmd == NULL) 7316 { 7317 cmd = "???"; 7318 cmdsize = 3; 7319 } 7320 /* Command name is encoded in locale-coding-system; decode it. */ 7321 cmd_str = make_unibyte_string (cmd, cmdsize); 7322 decoded_cmd = code_convert_string_norecord (cmd_str, 7323 Vlocale_coding_system, 0); 7324 attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs); 7325 7326 if (q) 7327 { 7328 EMACS_INT ppid_eint, pgrp_eint, sess_eint, tpgid_eint, thcount_eint; 7329 p = q + 2; 7330 /* state ppid pgrp sess tty tpgid . minflt cminflt majflt cmajflt utime stime cutime cstime priority nice thcount . start vsize rss */ 7331 sscanf (p, "%c %d %d %d %d %d %*u %lu %lu %lu %lu %Lu %Lu %Lu %Lu %ld %ld %d %*d %Lu %lu %ld", 7332 &c, &ppid, &pgrp, &sess, &tty, &tpgid, 7333 &minflt, &cminflt, &majflt, &cmajflt, 7334 &utime, &stime, &cutime, &cstime, 7335 &priority, &nice, &thcount, &start, &vsize, &rss); 7336 { 7337 char state_str[2]; 7338 7339 state_str[0] = c; 7340 state_str[1] = '\0'; 7341 tem = build_string (state_str); 7342 attrs = Fcons (Fcons (Qstate, tem), attrs); 7343 } 7344 /* Stops GCC whining about limited range of data type. */ 7345 ppid_eint = ppid; 7346 pgrp_eint = pgrp; 7347 sess_eint = sess; 7348 tpgid_eint = tpgid; 7349 thcount_eint = thcount; 7350 attrs = Fcons (Fcons (Qppid, make_fixnum_or_float (ppid_eint)), attrs); 7351 attrs = Fcons (Fcons (Qpgrp, make_fixnum_or_float (pgrp_eint)), attrs); 7352 attrs = Fcons (Fcons (Qsess, make_fixnum_or_float (sess_eint)), attrs); 7353 attrs = Fcons (Fcons (Qttname, procfs_ttyname (tty)), attrs); 7354 attrs = Fcons (Fcons (Qtpgid, make_fixnum_or_float (tpgid_eint)), attrs); 7355 attrs = Fcons (Fcons (Qminflt, make_fixnum_or_float (minflt)), attrs); 7356 attrs = Fcons (Fcons (Qmajflt, make_fixnum_or_float (majflt)), attrs); 7357 attrs = Fcons (Fcons (Qcminflt, make_fixnum_or_float (cminflt)), attrs); 7358 attrs = Fcons (Fcons (Qcmajflt, make_fixnum_or_float (cmajflt)), attrs); 7359 clocks_per_sec = sysconf (_SC_CLK_TCK); 7360 if (clocks_per_sec < 0) 7361 clocks_per_sec = 100; 7362 attrs = Fcons (Fcons (Qutime, 7363 ltime_from_jiffies (utime, clocks_per_sec)), 7364 attrs); 7365 attrs = Fcons (Fcons (Qstime, 7366 ltime_from_jiffies (stime, clocks_per_sec)), 7367 attrs); 7368 attrs = Fcons (Fcons (Qcutime, 7369 ltime_from_jiffies (cutime, clocks_per_sec)), 7370 attrs); 7371 attrs = Fcons (Fcons (Qcstime, 7372 ltime_from_jiffies (cstime, clocks_per_sec)), 7373 attrs); 7374 attrs = Fcons (Fcons (Qpri, make_number (priority)), attrs); 7375 attrs = Fcons (Fcons (Qnice, make_number (nice)), attrs); 7376 attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (thcount_eint)), attrs); 7377 EMACS_GET_TIME (tnow); 7378 get_up_time (&sec, &usec); 7379 EMACS_SET_SECS (telapsed, sec); 7380 EMACS_SET_USECS (telapsed, usec); 7381 EMACS_SUB_TIME (tboot, tnow, telapsed); 7382 time_from_jiffies (start, clocks_per_sec, &sec, &usec); 7383 EMACS_SET_SECS (tstart, sec); 7384 EMACS_SET_USECS (tstart, usec); 7385 EMACS_ADD_TIME (tstart, tboot, tstart); 7386 attrs = Fcons (Fcons (Qstart, 7387 list3 (make_number 7388 ((EMACS_SECS (tstart) >> 16) & 0xffff), 7389 make_number 7390 (EMACS_SECS (tstart) & 0xffff), 7391 make_number 7392 (EMACS_USECS (tstart)))), 7393 attrs); 7394 attrs = Fcons (Fcons (Qvsize, make_fixnum_or_float (vsize/1024)), attrs); 7395 attrs = Fcons (Fcons (Qrss, make_fixnum_or_float (4*rss)), attrs); 7396 EMACS_SUB_TIME (telapsed, tnow, tstart); 7397 attrs = Fcons (Fcons (Qetime, 7398 list3 (make_number 7399 ((EMACS_SECS (telapsed) >> 16) & 0xffff), 7400 make_number 7401 (EMACS_SECS (telapsed) & 0xffff), 7402 make_number 7403 (EMACS_USECS (telapsed)))), 7404 attrs); 7405 time_from_jiffies (utime + stime, clocks_per_sec, &sec, &usec); 7406 pcpu = (sec + usec / 1000000.0) / (EMACS_SECS (telapsed) + EMACS_USECS (telapsed) / 1000000.0); 7407 if (pcpu > 1.0) 7408 pcpu = 1.0; 7409 attrs = Fcons (Fcons (Qpcpu, make_float (100 * pcpu)), attrs); 7410 pmem = 4.0 * 100 * rss / procfs_get_total_memory (); 7411 if (pmem > 100) 7412 pmem = 100; 7413 attrs = Fcons (Fcons (Qpmem, make_float (pmem)), attrs); 7414 } 7415 } At conditional (16): "fd >= 0" taking true path 7416 if (fd >= 0) 7417 emacs_close (fd); 7418 7419 /* args */ 7420 strcpy (procfn_end, "/cmdline"); 7421 fd = emacs_open (fn, O_RDONLY, 0); At conditional (17): "fd >= 0" taking true path 7422 if (fd >= 0) 7423 { At conditional (18): "emacs_read == 1" taking true path At conditional (20): "emacs_read == 1" taking false path 7424 for (cmdline_size = 0; emacs_read (fd, &c, 1) == 1; cmdline_size++) 7425 { At conditional (19): "*(*__ctype_b_loc + (c * 2)) & 8192 != 0" taking true path 7426 if (isspace (c) || c == '\\') 7427 cmdline_size++; /* for later quoting, see below */ 7428 } At conditional (21): "cmdline_size != 0" taking false path 7429 if (cmdline_size) 7430 { 7431 cmdline = xmalloc (cmdline_size + 1); 7432 lseek (fd, 0L, SEEK_SET); 7433 cmdline[0] = '\0'; 7434 if ((nread = read (fd, cmdline, cmdline_size)) >= 0) 7435 cmdline[nread++] = '\0'; 7436 /* We don't want trailing null characters. */ 7437 for (p = cmdline + nread - 1; p > cmdline && !*p; p--) 7438 nread--; 7439 for (p = cmdline; p < cmdline + nread; p++) 7440 { 7441 /* Escape-quote whitespace and backslashes. */ 7442 if (isspace (*p) || *p == '\\') 7443 { 7444 memmove (p + 1, p, nread - (p - cmdline)); 7445 nread++; 7446 *p++ = '\\'; 7447 } 7448 else if (*p == '\0') 7449 *p = ' '; 7450 } 7451 cmdline_size = nread; 7452 } 7453 else 7454 { 7455 cmdline_size = cmdsize + 2; 7456 cmdline = xmalloc (cmdline_size + 1); 7457 strcpy (cmdline, "["); Event uninit_arg: Using uninitialized value "cmd" as argument to function "strncat" Also see events: [var_decl] 7458 strcat (strncat (cmdline, cmd, cmdsize), "]"); 7459 } 7460 emacs_close (fd); 7461 /* Command line is encoded in locale-coding-system; decode it. */ 7462 cmd_str = make_unibyte_string (cmdline, cmdline_size); 7463 decoded_cmd = code_convert_string_norecord (cmd_str, 7464 Vlocale_coding_system, 0); 7465 xfree (cmdline); 7466 attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs); 7467 } 7468 7469 UNGCPRO; 7470 return attrs; 7471 }