[PATCH 1 of 2 stable] worker: do not suppress EINTR
Yuya Nishihara
yuya at tcha.org
Wed May 25 12:55:55 UTC 2022
On Wed, 25 May 2022 02:30:29 +0200, Manuel Jacob wrote:
> # HG changeset patch
> # User Manuel Jacob <me at manueljacob.de>
> # Date 1653433864 -7200
> # Wed May 25 01:11:04 2022 +0200
> # Branch stable
> # Node ID d058898bdd462b03c5bff38ad40d1f855ea51c23
> # Parent 477b5145e1a02715f846ce017b460858a58e03b1
> # EXP-Topic worker-pickle-load-EINTR
> worker: do not suppress EINTR
>
> Before this change, when IOError with errno EINTR was raised during
> pickle.load(), the error was suppressed and loading from other file descriptors
> was continued.
>
> On Python 3, system calls failing with EINTR are retried (PEP 475). Therefore,
> the removal of this code should not make any difference.
>
> On Python 2, this is not generally the case. CPickle has no handling of EINTR.
> In one place it misinterprets it as EOF. In another place, it will raise
> IOError. However, this could happen in the middle of the stream. In this case,
> if pickle tries to load from the stream later, it will behave wrongly (usually
> it will raise an error, but loading of incorrect data or interpreter crashes
> are thinkable).
Do we want this (and the partial write fix) on stable?
The problem could occur if the payload were quite large, but I think it's
unlikely. Since writer issues a single os.write() in the original code,
reader wouldn't be interrupted in the middle of pickle message in general.
We don't have to think about Python 2 on default, so the patches will get
simplified.
More information about the Mercurial-devel
mailing list