From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 7A86B3858CDA; Tue, 10 Jan 2023 13:16:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A86B3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673356585; bh=P9frQiIBd5rG66abrcpgPqprHaHijKK47tVNMx12rHw=; h=From:To:Subject:Date:From; b=ZCkHrPCPMxAZEYowQmyEoeM74bvvw19xitXo3YvA6/xwkRXKtdGxmRy2OzfmTPA8u 7XfcnRtuT4kMGfEj7WcDxn7hQuUQacuJ0MI2Ku5Br1v2CJBHA3BfrBX06p45vZHWBX 5BUHQ4xm4coT+rVf5uaVKcmVANrazD22BpQyNX24= 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-3_4-branch] Cygwin: cygheap: Initialize myself_pinfo before child_copy(). X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/cygwin-3_4-branch X-Git-Oldrev: a4584410fc24486eae272c6e6a582eb27757314c X-Git-Newrev: 1069eab80aa6e9f195e8bf1f04e49f9d23d41bc5 Message-Id: <20230110131625.7A86B3858CDA@sourceware.org> Date: Tue, 10 Jan 2023 13:16:25 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D1069eab80aa= 6e9f195e8bf1f04e49f9d23d41bc5 commit 1069eab80aa6e9f195e8bf1f04e49f9d23d41bc5 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 a305570df..609407656 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);