[PATCH] tests: fix toctou race in tinyproxy.py (issue3795)

Matt Mackall mpm at selenic.com
Thu Jan 31 17:09:58 CST 2013


On Thu, 2013-01-31 at 16:12 -0500, Augie Fackler wrote:
> 
> On Jan 31, 2013, at 3:06 PM, Matt Mackall <mpm at selenic.com> wrote:
> 
> > On Thu, 2013-01-31 at 20:01 +0100, Mads Kiilerich wrote:
> > > # HG changeset patch
> > > # User Mads Kiilerich <madski at unity3d.com>
> > > # Date 1359655993 -3600
> > > # Branch stable
> > > # Node ID 9f4ee36491d826a0714164721e631f026d63b324
> > > # Parent  2a1fac3650a5b4d650198604c82ab59969500374
> > > tests: fix toctou race in tinyproxy.py (issue3795)
> > 
> > Looks good.
> 
> 
> FWIW, this freaks me out a little bit - I don't understand why there'd
> be a econnreset here. I may just not have spent enough time squinting
> at the code.

That occurs when we try to write to a socket the remote side has closed.
So that's maybe a real bug in either our client (writing too much) or
our server (hanging up early).

But the proximal bug is actually in the select loop in tinyproxy. It
depends on exceptional conditions to exit the loop, but it's perfectly
valid for ECONNRESET to show up in the read vector. The vagarities of
scheduling and flow control may make this happen differently under load.
        
        From Richard Stevens (rstevens at noao.edu):
        
        [...] What this also means is that if you were using select
        instead of write, the select would have indicated the socket as
        being readable, since the RST is there for you to read (read
        will return an error with errno set to ECONNRESET).

So I think this fix is correct, at least locally.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list