From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: Segmentation fault due to double free for archetype.
Date: Mon, 17 Jan 2022 20:41:31 +0900 [thread overview]
Message-ID: <20220117204131.b1b3e221874af6804791ccec@nifty.ne.jp> (raw)
In-Reply-To: <YeVMn4MIgG+6T01I@calimero.vinschen.de>
On Mon, 17 Jan 2022 12:01:51 +0100
Corinna Vinschen wrote:
> On Jan 15 19:20, Takashi Yano wrote:
> > I also found the following patch fixes the issue. Is this the
> > right thing?
> >
> > diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
> > index fc7c0422e..e51208117 100644
> > --- a/winsup/cygwin/fhandler.cc
> > +++ b/winsup/cygwin/fhandler.cc
> > @@ -441,7 +441,7 @@ fhandler_base::open_with_arch (int flags, mode_t mode)
> > || open (flags, mode & 07777)))
> > {
> > if (archetype)
> > - delete archetype;
> > + cygheap->fdtab.delete_archetype (archetype);
> > }
> > else if (archetype)
> > {
>
> Good catch! I think this is basically ok, but you have to check the
> usecount, i. e.
>
> if (archetype && archetype_usecount (-1) == 0)
> cygheap->fdtab.delete_archetype (archetype);
>
> Does that sound right?
Where is archetype->usecount is incremented? It seems that
archetype->usecount is zero here. archetype->usecount is not
incremented around line 672 in dtable.cc when archetype is
created by fh->clone().
else
{
if (!fh->get_name ())
fh->set_name (fh->dev ().native ());
fh->archetype = fh->clone ();
debug_printf ("created an archetype (%p) for %s(%d/%d)", fh->archetype, fh->get_name (), fh->dev ().get_major (), fh->dev ().get_minor ());
fh->archetype->archetype = NULL;
*cygheap->fdtab.add_archetype () = fh->archetype;
}
--
Takashi Yano <takashi.yano@nifty.ne.jp>
next prev parent reply other threads:[~2022-01-17 11:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-15 10:20 Takashi Yano
2022-01-17 11:01 ` Corinna Vinschen
2022-01-17 11:41 ` Takashi Yano [this message]
2022-01-17 12:11 ` Corinna Vinschen
2022-01-17 12:48 ` Takashi Yano
2022-01-17 15:47 ` Corinna Vinschen
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=20220117204131.b1b3e221874af6804791ccec@nifty.ne.jp \
--to=takashi.yano@nifty.ne.jp \
--cc=cygwin@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).