Bug 109147 - vmstat dies parsing /proc/stats
vmstat dies parsing /proc/stats
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: procps (Show other bugs)
3.0
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Karel Zak
:
Depends On:
Blocks: 132991
  Show dependency treegraph
 
Reported: 2003-11-04 18:52 EST by Shantanu Goel
Modified: 2007-11-30 17:06 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-05-19 23:25:49 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Shantanu Goel 2003-11-04 18:52:04 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1)
Gecko/20031009

Description of problem:
Running "vmstat 3" eventually dies with the following error:

open: No such file or directory
error: failed to parse /proc/stats


I am running kernel-smp-2.4.22-1.2115.nptl on a Dell 1600SC with dual
Xeon CPUs.  I have encountered this error with earlier test kernels as
far back as 2088 as well.


Version-Release number of selected component (if applicable):
procps-2.0.17-1

How reproducible:
Sometimes

Steps to Reproduce:
Run "vmstat 3".

Actual Results:  vmstat dies eventually.  The timing is erratic but
pretty much reproducible every time.

Additional info:
Comment 1 Daniel Walsh 2004-02-11 08:56:27 EST
Can you reproduce this with procps 3.1.15?
Comment 2 Brian Hirt 2004-07-27 14:28:58 EDT
this seems to be fixed in procps 3.x, but exists in procps 2.0.17 which is what core one 
uses.   I have the answer to this problem.:

I did a strace and looked at the code and i've found what i think is a problem.  there is a 
race condition in getrunners() if a program exits between the readdir(proc) and the open() 
vmstat will die.    if /proc/pid/stat is missing, I think it should be assumed that the 
process has died, and continue gracefully if the errno is file not found.  look at line 48 
vmstat.c in 2.0.17


strace reveals:

open("/proc/16928/stat", O_RDONLY)      = 5
read(5, "16928 (bash) S 16908 10483 4568 "..., 1023) = 209
close(5)                                = 0
open("/proc/16929/stat", O_RDONLY)      = -1 ENOENT (No such file or directory)
dup(2)                                  = 5
fcntl64(5, F_GETFL)                     = 0x2 (flags O_RDWR)
fstat64(5, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xbf512000
_llseek(5, 0, 0xbff811b8, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
write(5, "open: No such file or directory\n", 32open: No such file or directory
) = 32
close(5)                                = 0
munmap(0xbf512000, 4096)                = 0
write(2, "error: failed to parse /proc/sta"..., 35error: failed to parse /proc/stats
) = 35
munmap(0xbf513000, 4096)                = 0
exit_group(1)                           = ?
Comment 5 Karel Zak 2004-11-23 13:05:21 EST
For RHEL3 fixed in procps-2.0.17-13.1.
Comment 6 Dennis Gregorovic 2005-05-19 23:25:49 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2005-156.html

Note You need to log in before you can comment on or make changes to this bug.