From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-03.nifty.com (conssluserg-03.nifty.com [210.131.2.82]) by sourceware.org (Postfix) with ESMTPS id 2AD8C3858400 for ; Tue, 26 Oct 2021 09:26:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2AD8C3858400 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from Express5800-S70 (z221123.dynamic.ppp.asahi-net.or.jp [110.4.221.123]) (authenticated) by conssluserg-03.nifty.com with ESMTP id 19Q9QcG5001040 for ; Tue, 26 Oct 2021 18:26:39 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com 19Q9QcG5001040 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1635240399; bh=OUBR/Jzv8lW0cMykq6DwJvLs+72a5PQsNeDbgy1w8gQ=; h=Date:From:To:Subject:In-Reply-To:References:From; b=E4tWtSBheuX4emCe5J8ouYnWz1i5M1M1KSTfjkr/A+vzW3R397Vj/LlmtRks9YZfG R1EBj4l2Mmn6kwsjDVDfhmW7IC3oeveyLXEFZXL8cQjpLKPH+nni29MO+uqWzQ2ydm 2SCVPWJUxdKDs4Zn+L/PyiktuJSsv2l5bx3UieV48jprPhCS5I2DcC+u5EjoD6nqgY O0mX11rk2NfltzWKwOJ1laF3xwHoMH4s1IZzjmmIxuU5r7If6jWuuEwV75fIgA1izr I/L0CVApr/vdHnb50p49WX4Rs7X1a5BfbANnyIe/gnL6UWyFGJFAQ6+v1b2lWdMqwG i8yrsgC41k7NQ== X-Nifty-SrcIP: [110.4.221.123] Date: Tue, 26 Oct 2021 18:26:39 +0900 From: Takashi Yano To: cygwin-developers@cygwin.com Subject: Re: malloc crash Message-Id: <20211026182639.92f6f9de086ec35f41deef88@nifty.ne.jp> In-Reply-To: References: <6a4d6675-7e4d-bcb3-9aff-acc0788d211d@cornell.edu> <97873b16-7ec3-02d7-1861-3ec62a79c37e@cornell.edu> <4b322eb0-4941-6b8f-6f46-aa76caf5a66f@cornell.edu> <2819d0db-3c5c-2d31-2b21-91efafb7f8f4@maxrnd.com> <20211026091855.7aaf2de97d10174121cbc8f9@nifty.ne.jp> <20211026175229.1eda36caab1b03314a8cf165@nifty.ne.jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Oct 2021 09:27:01 -0000 On Tue, 26 Oct 2021 01:59:36 -0700 Mark Geisert wrote: > Takashi Yano wrote: > > On Tue, 26 Oct 2021 01:30:13 -0700 > > Mark Geisert wrote: > >> Apologies; this was many months ago. What I did try was moving the malloc_init() > >> to before running the constructor chain, as Takashi suggested. That is what gave > >> me more problems. I don't recall what they were, but I reverted that attempt. > >> > >> The "future malloc" build of Cygwin I'm running doesn't exhibit Ken's issue, as > >> far as I can tell. It has a specific fix to avoid the scenario I've been talking > >> about here, but I don't want to take us down that path unless we're sure Ken's > >> hitting that same scenario. > > > > I tried the following patch, and confirmed that the issue has > > been disappeared. I do not notice any other problems so far > > with this patch. > > > > diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc > > index 6f4723bb0..0d541ec14 100644 > > --- a/winsup/cygwin/dcrt0.cc > > +++ b/winsup/cygwin/dcrt0.cc > > @@ -773,6 +773,10 @@ dll_crt0_0 () > > do_global_ctors (&__CTOR_LIST__, 1); > > ^^^^^^^^^^^^^^^ > > > cygthread::init (); > > > > + /* malloc_init() has been moved from dll_crt0_1() to here so that > > + malloc() can be called in fixup_after_exec(). */ > > + malloc_init (); > > + > > if (!child_proc_info) > > { > > setup_cygheap (); > > @@ -857,7 +861,7 @@ dll_crt0_1 (void *) > > on a functioning malloc and it's possible that the user's program may > > have overridden malloc. We only know about that at this stage, > > unfortunately. */ > > - malloc_init (); > > + /* malloc_init() has been moved to dll_crt0_0(). */ > > user_shared->initialize (); > > > > #ifdef CYGHEAP_DEBUG > > > > > > Where is the "constructor chain" you mentioned? > > See above. Try moving your new lines above the call to do_global_ctors(). Also > note the comment just above the original location of those lines.. you're now > ignoring what the comment warns about. I have just tried moving malloc_init() before do_global_ctors(), however, I do not encountered any problems. I do not understand what "user's program may have overridden malloc" means... -- Takashi Yano