Incorrect handling of EINTR in Bazaar

Gregory P. Smith greg at krypto.org
Tue Feb 16 06:58:25 GMT 2010


On Mon, Feb 15, 2010 at 9:27 PM, Martin Pool <mbp at canonical.com> wrote:

> On 16 February 2010 13:01, Martin (gzlist) <gzlist at googlemail.com> wrote:
> > On 16/02/2010, Martin Pool <mbp at canonical.com> wrote:
> >>
> >> We still support python back to 2.4; considering the deployed
> >> environment of interpreters we prefer to work around bugs in Python if
> >> at all feasible.
> >
> > The existing code does not work on either Python 2.4 or Python 2.5 so
> > a backout can't do any harm there. Whether it's worth addressing this
> > (mostly harmless) corner case on old versions is your call, getting
> > the solid fix in a 2.6 dot release is by far the cleanest option.
>
> ...
>
> >> Yes, but isn't it harmless to check for them?
> >>
> >> Similarly, I raised the issue in review that some python calls already
> >> handle eintr or partial reads, but it seems harmless to check for it.
> >
> > There is some harm, first it still causes the bugs as with module
> > cleanup, second it misleads people reading the code. Keeping a few
> > catches that won't do anything on some platforms is reasonable though.
> >
> >> So perhaps we should have a decorator object that does handle eintr
> >> and install that only when needed?
> >
> > The problem is the check is needed in several cases where there is
> > nothing you can do in client code but die, as it's not possible to
> > resume. There are options when it comes to a complete fix, I can
> > prepare a couple of branches for review and y'all can pick one.
>
> OK, I see.  From your first mail I thought you meant that there were
> just checks around some lower-level routines that would never raise
> it.  But you're saying that some Python library routines may propagate
> eintr, but they can't be safely restarted?  That certainly sucks.
> Perhaps we can avoid these routines altogether, using socket.recv
> directly rather than socket objects?
>

Yeah there certainly were Python bugs that could result in an EINTR
exception being raised from a non-restartable api.  See [3] for the changes
to fix that.

sendall() is easy to implement in python.  fixing the read and readline
methods is more work but you could probably monkeypatch good implementations
in or even conditionally backport and monkeypatch part or all of socket.py
from trunk.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/bazaar/attachments/20100215/7b46e90c/attachment-0001.htm 


More information about the bazaar mailing list