From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: fix off-by-one in dup2
Date: Wed, 04 Dec 2013 11:36:00 -0000 [thread overview]
Message-ID: <20131204113626.GB29444@calimero.vinschen.de> (raw)
In-Reply-To: <20131204093238.GA28314@calimero.vinschen.de>
[-- Attachment #1: Type: text/plain, Size: 2258 bytes --]
On Dec 4 10:32, Corinna Vinschen wrote:
> Hi guys,
>
>
> I'm not quite sure yet *why* this happens, but this change in
> dtable::find_unused_handle...
>
> On Sep 25 17:26, Eric Blake wrote:
> > [...]
> > diff --git i/winsup/cygwin/dtable.cc w/winsup/cygwin/dtable.cc
> > index 2501a26..c2982a8 100644
> > --- i/winsup/cygwin/dtable.cc
> > +++ w/winsup/cygwin/dtable.cc
> > @@ -233,7 +233,7 @@ dtable::find_unused_handle (int start)
> > if (fds[i] == NULL)
> > return i;
> > }
> > - while (extend (NOFILE_INCR));
> > + while (extend (MAX (NOFILE_INCR, start - size)));
> > return -1;
> > }
>
> ...introduced the problem reported in
> http://cygwin.com/ml/cygwin/2013-12/msg00072.html
>
> The problem is still present in the current sources.
>
> If I apply this change...
>
> Index: dtable.cc
> ===================================================================
> RCS file: /cvs/src/src/winsup/cygwin/dtable.cc,v
> retrieving revision 1.275
> diff -u -p -r1.275 dtable.cc
> --- dtable.cc 1 Dec 2013 19:17:56 -0000 1.275
> +++ dtable.cc 4 Dec 2013 09:26:01 -0000
> @@ -223,7 +223,8 @@ dtable::delete_archetype (fhandler_base
> int
> dtable::find_unused_handle (size_t start)
> {
> - size_t extendby = (start >= size) ? 1 + start - size : NOFILE_INCR;
> + //size_t extendby = (start >= size) ? 1 + start - size : NOFILE_INCR;
> + size_t extendby = NOFILE_INCR;
>
> /* This do loop should only ever execute twice. */
> int res = -1;
>
>
> ..., which essentially reverts the original change from Eric, the
> problem is fixed.
>
> Off the top of my head I don't understand why Eric's as well as cgf's
> solution (which are not equivalent) both introduce this problem, but
> always using NOFILE_INCR works, so I publish it here for discussion.
>
> I'm off for a doc appointment now, maybe I have some clue while sitting
> in the anteroom.
Not really. Btw., this helps to fix the problem as well:
size_t extendby = (start >= size) ? MAX (1 + start - size, NOFILE_INCR)
: NOFILE_INCR;
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-12-04 11:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-25 23:26 Eric Blake
2013-10-15 14:06 ` Christopher Faylor
2013-10-15 20:45 ` Yaakov (Cygwin/X)
2013-10-15 22:34 ` Christopher Faylor
2013-10-16 7:40 ` Yaakov (Cygwin/X)
2013-11-23 13:19 ` Eric Blake
2013-12-04 9:32 ` Corinna Vinschen
2013-12-04 11:36 ` Corinna Vinschen [this message]
2013-12-04 12:04 ` Corinna Vinschen
2013-12-04 17:00 ` Christopher Faylor
2013-12-04 17:23 ` Corinna Vinschen
2013-12-04 17:51 ` Christopher Faylor
2013-12-04 19:44 ` Corinna Vinschen
2013-12-05 13:45 ` Eric Blake
2013-12-05 19:56 ` Christopher Faylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131204113626.GB29444@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin-patches@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).