public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Takashi Yano <tyan0@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: cygheap: Initialize myself_pinfo before child_copy().
Date: Tue, 10 Jan 2023 13:15:47 +0000 (GMT)	[thread overview]
Message-ID: <20230110131547.2CBBE3858D33@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a81fef51cf9f1b9fad73ad85826f02f40d85fda6

commit a81fef51cf9f1b9fad73ad85826f02f40d85fda6
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Tue Jan 10 21:04:29 2023 +0900

    Cygwin: cygheap: Initialize myself_pinfo before child_copy().
    
    After the commit 30add3e6b3e3, the problem:
    https://cygwin.com/pipermail/cygwin/2022-December/252759.html
    occurs rarely. It seems that myself_pinfo should be initialized
    where the timing before child_copy() and after cygheap allocation.
    This patch moves the initialization there.
    
    Fixes: 30add3e6b3e3 ("Cygwin: exec: don't access cygheap before it's
    initialized")
    Reported-by: Brian Inglis <Brian.Inglis@Shaw.ca>
    Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>

Diff:
---
 winsup/cygwin/dcrt0.cc      | 2 --
 winsup/cygwin/mm/cygheap.cc | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 5c5a280cc..49b7a44ae 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -631,8 +631,6 @@ child_info_spawn::handle_spawn ()
   if (!dynamically_loaded || get_parent_handle ())
       {
 	cygheap_fixup_in_child (true);
-	if (dynamically_loaded)
-	  moreinfo->myself_pinfo = NULL;
 	memory_init ();
       }
 
diff --git a/winsup/cygwin/mm/cygheap.cc b/winsup/cygwin/mm/cygheap.cc
index 72861d8d7..6a20c159a 100644
--- a/winsup/cygwin/mm/cygheap.cc
+++ b/winsup/cygwin/mm/cygheap.cc
@@ -95,6 +95,8 @@ cygheap_fixup_in_child (bool execed)
   cygheap = (init_cygheap *) VirtualAlloc ((LPVOID) CYGHEAP_STORAGE_LOW,
 					   commit_size, MEM_COMMIT,
 					   PAGE_READWRITE);
+  if (dynamically_loaded && execed)
+    spawn_info->moreinfo->myself_pinfo = NULL;
   cygheap_max = child_proc_info->cygheap_max;
   child_copy (child_proc_info->parent, false, child_proc_info->silentfail (),
 	      "cygheap", cygheap, cygheap_max, NULL);

                 reply	other threads:[~2023-01-10 13:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230110131547.2CBBE3858D33@sourceware.org \
    --to=tyan0@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /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).