Bug 109147

Summary: vmstat dies parsing /proc/stats
Product: Red Hat Enterprise Linux 3 Reporter: Shantanu Goel <sgoel01>
Component: procpsAssignee: Karel Zak <kzak>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: laroche
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-05-20 03:25:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 132991    

Description Shantanu Goel 2003-11-04 23:52:04 UTC
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 13:56:27 UTC
Can you reproduce this with procps 3.1.15?

Comment 2 Brian Hirt 2004-07-27 18:28:58 UTC
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 18:05:21 UTC
For RHEL3 fixed in procps-2.0.17-13.1.

Comment 6 Dennis Gregorovic 2005-05-20 03:25:49 UTC
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