X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 58A863858030
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1642434529;
	bh=PibnueCe0sb8dCKHOpRFa9h4joDENabF15DFHoo/klM=;
	h=Date:From:To:Subject:References:In-Reply-To:List-Id:
	 List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
	 Reply-To:From;
	b=NuxrdRCoSJiwoxdz6FxVVFe4KrdsYUeCJHXKM0md0tR+kl6RQ+rHbTIUDDh7zPUOK
	 UIRQcp72p/aKUJ1R3duoMumlqqS9UwayjIg6D3ZE1YL4GoRdrni2QeAORzXPUV64Bz
	 GQNjFBTvjUqTvYlGPjlrZbH41I1UBUvVGHHpPPVo=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 981923858D3C
Authentication-Results: sourceware.org;
 dmarc=fail (p=none dis=none) header.from=cygwin.com
Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com
Date: Mon, 17 Jan 2022 16:47:35 +0100
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Segmentation fault due to double free for archetype.
Message-ID: <YeWPlyHklwqrYH1j@calimero.vinschen.de>
Mail-Followup-To: cygwin@cygwin.com
References: <20220115192030.de26356820d839eec3227e70@nifty.ne.jp>
 <YeVMn4MIgG+6T01I@calimero.vinschen.de>
 <20220117204131.b1b3e221874af6804791ccec@nifty.ne.jp>
 <YeVdAnpZ0eUAfEoF@calimero.vinschen.de>
 <20220117214801.1f0d9bef92224cac51b6d806@nifty.ne.jp>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <20220117214801.1f0d9bef92224cac51b6d806@nifty.ne.jp>
X-Provags-ID: V03:K1:f4IySGuQza40o4EHZU6xJ4/BjhmDoCLAI9R7hxUgGbtzFO53HNi
 Xi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ARC_STATUS, RCVD_IN_DNSWL_NONE,
 RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_FAIL, SPF_HELO_NONE,
 TXREP autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
Reply-To: cygwin@cygwin.com
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

On Jan 17 21:48, Takashi Yano wrote:
> On Mon, 17 Jan 2022 13:11:46 +0100
> Corinna Vinschen wrote:
> >   if (!(res = (archetype && archetype->io_handle)
> >         || open (flags, mode & 07777)))
> > 
> > Then the archetype is one already created by a former open_with_arch
> > call and then you delete an archetype which is still in use, no?
> 
> archetype->usecount is not incremented yet here.
> archetype->usecount is incremented only when this 'if' clause
> is not true. So, isn't the following code right?
> 
>   if (!(res = (archetype && archetype->io_handle)
>         || open (flags, mode & 07777)))
>     {
>       if (archetype && archetype->usecount == 0)
>         cygheap->fdtab.delete_archetype (archetype);
>     }

Good point, yes, that sounds right to me.


Thanks,
Corinna

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
