X-Recipient: archive-cygwin AT delorie DOT com X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 802AE3856DFC 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 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com 23SF1m8V001709 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1651158108; bh=bq6AVs7R5/huc2RIARH1eQJitbjYD0e5OAXbM1sVsGw=; h=Date:From:To:Subject:In-Reply-To:References:From; b=Vvzk+Q9q+htnOjhvm0VXthwASalIYeJiSP9k53MGhgwlgtREdTWJWlUzIVPoh7oxe vk5PM4UVGsFoJNqmuL45N1FrtM6pYgi2yslO6dWivvy22pRrckaW0SfjRiLsOaMBhA t2l90LBtMpOtJEQx13cqUN4em9UUzc7PxvqMi8UH55k74rIX/0xWh/xOl3tEzOB4UZ oUY2Or3KEru2WEwQ1rb1jI4Ga63FhRT+L8Xxz+V8nrxLgQuhg+JZMWOZeV+qtwtdsQ QynyyCZX+EfUwzcdtAZ4gWNcIDj12HqfvKPZEzm8Et5Nl9WuquQM757q/UhsETmjsa 2EcphNK9Nt8Lg== X-Nifty-SrcIP: [119.150.44.95] Date: Fri, 29 Apr 2022 00:01:52 +0900 From: Takashi Yano To: cygwin AT cygwin DOT com Subject: Re: GNU make losing jobserver tokens Message-Id: <20220429000152.1fe838469e543a69586e194d@nifty.ne.jp> In-Reply-To: References: <9b9da583-124d-9d5f-4c10-6622602ca8dc AT oracle DOT com> <20220401174551 DOT 820cbc148852554108397e03 AT nifty DOT ne DOT jp> <20220427231340 DOT 0bdab2d6d903dd4fb44bd12f AT nifty DOT ne DOT jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 X-Spam-Status: No, score=-10.6 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, 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 AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" On Thu, 28 Apr 2022 16:09:24 +0200 Corinna Vinschen wrote: > On Apr 28 09:42, Ken Brown wrote: > > On 4/27/2022 10:13 AM, Takashi Yano wrote: > > > On Fri, 1 Apr 2022 17:45:51 +0900 > > > Takashi Yano wrote: > > > > I have tried to reproduce the issue by building OpenJDK > > > > from source, however, I could not. > > > > > > > > Instead, I encountered another issue. > > > > > > > > Building OpenJDK sometimes (rarely) failed with error such as: > > > > > > > > 0 [sig] make 5484 sig_send: error sending signal 11, pid 5484, pipe handle 0x118, nb 0, packsize 176, Win32 error 0 > > > > 124917 [main] make 5484 sig_send: error sending signal -72, pid 5484, pipe handle 0x118, nb 0, packsize 176, Win32 error 0 > > > > common/modules/GensrcModuleInfo.gmk:77: *** open: /home/yano/jdk/build/windows-x86-server-release/make-support/vardeps/make/common/modules/GensrcModuleInfo.gmk/jdk.accessibility/ALL_MODULES.vardeps: No such file or directory. Stop. > > > > make[2]: *** [make/Main.gmk:141: jdk.accessibility-gensrc-moduleinfo] Error 2 > > > > make[2]: *** Waiting for unfinished jobs.... > > > > > > > > > > > > I looked into this new problem and found that wait_sig() thread > > > > crashes with segfault. It seems that accessing _main_tls causes > > > > access violation if a signal is sent just after the process is > > > > started. > > > > > > > > static void WINAPI > > > > wait_sig (VOID *) > > > > { > > > > [...] > > > > if (!pack.mask) > > > > { > > > > tl_entry = cygheap->find_tls (_main_tls); > > > > dummy_mask = _main_tls->sigmask; // <--- Segfault here > > > > cygheap->unlock_tls (tl_entry); > > > > pack.mask = &dummy_mask; > > > > } > > > > > > > > I also found the following patch resolves the issue. > > > > > > > > diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc > > > > index 62df96652..3824af199 100644 > > > > --- a/winsup/cygwin/sigproc.cc > > > > +++ b/winsup/cygwin/sigproc.cc > > > > @@ -1325,6 +1325,10 @@ wait_sig (VOID *) > > > > _sig_tls = &_my_tls; > > > > bool sig_held = false; > > > > + /* Wait for _main_tls initialization. */ > > > > + while (!cygwin_finished_initializing) > > > > + Sleep (10); > > > > + > > > > sigproc_printf ("entering ReadFile loop, my_readsig %p, my_sendsig %p", > > > > my_readsig, my_sendsig); > > > > > > > > I guess _main_tls may not be initialized correctly until > > > > cygwin_finished_initializing is set. > > > > > > > > Any comments would be appreciated. > > > > This seems reasonable to me. Thanks Ken and Corinna. > Missed that, sorry. I agree this seems reasonable, but wouldn't it be > cleaner if we *start* wait_sig only after cygwin_finished_initializing > is set to true? I also thought so, however, there is a comment in dcrt0.cc as follows. So, there seems to be some reason to start wait_sig before cygwin_finished_initialization. /* Initialize signal processing here, early, in the hopes that the creation of a thread early in the process will cause more predictability in memory layout for the main thread. */ if (!dynamically_loaded) sigproc_init (); -- Takashi Yano -- 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