From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 2CBBE3858D33; Tue, 10 Jan 2023 13:15:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CBBE3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673356547; bh=RJFRVHLweoUA5W1gNPcIC7+IaU0KWHeLeSV8KIgaESo=; h=From:To:Subject:Date:From; b=OefQWCpKi34vR9BkVbG/5p7IGdNZOhvXGVQxLZuP4YMgRjnPoesOIhz+bEYAhL+jl c1F+FYuGoSeBkDSysNuSbNXykcZfDmH+8mXcrmrk1oKOqlDSQl3I5yK0Id5e58UiXe voinEgyzRJe8oWHwUgkskOcUmtxwT93MAJrBcxhw= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: cygheap: Initialize myself_pinfo before child_copy(). X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 7c14e5a10add3ad3dc53ed6af1ad2044d205e844 X-Git-Newrev: a81fef51cf9f1b9fad73ad85826f02f40d85fda6 Message-Id: <20230110131547.2CBBE3858D33@sourceware.org> Date: Tue, 10 Jan 2023 13:15:47 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Da81fef51cf9= f1b9fad73ad85826f02f40d85fda6 commit a81fef51cf9f1b9fad73ad85826f02f40d85fda6 Author: Takashi Yano Date: Tue Jan 10 21:04:29 2023 +0900 Cygwin: cygheap: Initialize myself_pinfo before child_copy(). =20 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. =20 Fixes: 30add3e6b3e3 ("Cygwin: exec: don't access cygheap before it's initialized") Reported-by: Brian Inglis Reviewed-by: Corinna Vinschen Signed-off-by: Takashi Yano 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 =3D NULL; memory_init (); } =20 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 =3D (init_cygheap *) VirtualAlloc ((LPVOID) CYGHEAP_STORAGE_LOW, commit_size, MEM_COMMIT, PAGE_READWRITE); + if (dynamically_loaded && execed) + spawn_info->moreinfo->myself_pinfo =3D NULL; cygheap_max =3D child_proc_info->cygheap_max; child_copy (child_proc_info->parent, false, child_proc_info->silentfail = (), "cygheap", cygheap, cygheap_max, NULL);