Re: Interesting race condition...

Rob Landley
2004-07-28T16:46:50Z

On Wednesday 28 July 2004 06:54, Marc Ballarin wrote:
> On Wed, 28 Jul 2004 01:05:46 -0700
>
> Paul Jackson <pj@sgi.com> wrote:
> > Rob wrote:
> > > I just saw a funky thing. Here's the cut and past from the xterm...
> >
> > Can you reproduce this by cat'ing /proc/<pid>/cmdline? Can you get a
> > dump of the proc cmdline file to leak the environment sometimes?
> >
> > It is this file that 'ps' is dumping for these options. Adding the
> > 'e' option would also dump the /proc/<pid>/environ file (if readable).
> >
> > But you aren't adding 'e', so presumably the environment is "leaking"
> > into the the cmdline file.
> >
> > I suspect a kernel bug here - the ps code seems rather obvious and
> > unimpeachable.
>
> I ran the following loop for a while (> 9 million times) and could not
> reproduce the bug, but that might just be coincidence.
> Conditions were the same as in my other, succesful test.
>
> while [ 1 ];do
> cat /proc/self/cmdline >> TEST
> done
>
> Marc

I might have actually just killed the process I was grepping for (I was
grepping to see if it had actually gone away yet). Dunno if that helps...

I haven't been able to reproduce it either. I think the pipe to grep (or
something similar) is important because your test isn't doing what mine did:
one process was looking at another process at the instant of process creation
(or perhaps exit). Maybe the appropriate null terminator is written out
after the process goes live?

This is a UP system, but I have preemption on...

Rob
--
www.linucon.org: Linux Expo and Science Fiction Convention
October 8-10, 2004 in Austin Texas. (I'm the con chair.)