From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-developers@cygwin.com
Subject: Re: Potential handle leaks in dup_worker
Date: Wed, 10 Feb 2021 10:52:50 +0100 [thread overview]
Message-ID: <20210210095250.GZ4251@calimero.vinschen.de> (raw)
In-Reply-To: <e5f56eb0-192c-58eb-a447-eb78bb3ebcdf@cornell.edu>
On Feb 9 17:31, Ken Brown via Cygwin-developers wrote:
> On 2/9/2021 3:52 PM, Corinna Vinschen via Cygwin-developers wrote:
> > On Feb 9 14:12, Ken Brown via Cygwin-developers wrote:
> > > Trying to make _copyto_reset_helper() protected leads to errors like this:
> > >
> > > In file included from ../../../../newlib-cygwin/winsup/cygwin/spawn.cc:22:
> > > ../../../../newlib-cygwin/winsup/cygwin/fhandler.h: In member function
> > > ‘virtual void fhandler_pty_master::copyto(fhandler_base*)’:
> > > ../../../../newlib-cygwin/winsup/cygwin/fhandler.h:2461:30: error: ‘void
> > > fhandler_base::_copyto_reset_helper()’ is protected within this context
> > > 2461 | x->_copyto_reset_helper ();
> > >
> > > As usual, my C++ knowledge is limited, but I guess the issue is that we're
> > > calling _copyto_reset_helper() on behalf of x. As an experiment, I removed
> > > 'x->', and the error message went away. I don't fully understand this. Do
> > > you see an easy way around it, or should I just leave _copyto_reset_helper()
> > > public?
> >
> > There's no easy way as such. I think the right approach is to turn the
> > copy-to method into a copy-from method, modifying "this", rather than
> > another object given as parameter. This is a more object-oriented
> > approach, IMHO. This also automagically fixes the problem that a
> > protected method can't be called in this context.
> >
> > Here's a patch fixing it this way. Can you please review it and see
> > if I missed something?
> >
> > Actually, on second thought, this should be split into two patches, one
> > removing the call to path_conv::operator<<, and the other one
> > reshuffling the code. If the patch is ok, I'll do that before pushing
> > it.
>
> LGTM. I agree that this is a better approach. My only other suggestion is
> that you consider removing path_conv::reset_conv_handle and replacing its
> two uses by close_conv_handle. Again this is to avoid the appearance of a
> handle leak, even though I'm pretty sure that the handle is always NULL when
> this is called.
Good idea. Done.
Thanks,
Corinna
prev parent reply other threads:[~2021-02-10 9:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-08 17:39 Ken Brown
2021-02-09 9:47 ` Corinna Vinschen
2021-02-09 14:19 ` Ken Brown
2021-02-09 15:02 ` Corinna Vinschen
2021-02-09 15:04 ` Corinna Vinschen
2021-02-09 15:31 ` Ken Brown
2021-02-09 16:12 ` Corinna Vinschen
2021-02-09 17:13 ` Ken Brown
2021-02-09 19:12 ` Ken Brown
2021-02-09 20:52 ` Corinna Vinschen
2021-02-09 22:31 ` Ken Brown
2021-02-10 9:52 ` Corinna Vinschen [this message]
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=20210210095250.GZ4251@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin-developers@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).