public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: cygheap: fix fork error after heap has grown Date: Tue, 18 Apr 2023 08:13:29 +0000 (GMT) [thread overview] Message-ID: <20230418081329.F148A3858412@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a14a0e542d3aa8e53d189c906205c92ad044f750 commit a14a0e542d3aa8e53d189c906205c92ad044f750 Author: David McFarland <corngood@gmail.com> AuthorDate: Mon Apr 17 21:41:55 2023 -0300 Commit: Corinna Vinschen <corinna@vinschen.de> CommitDate: Tue Apr 18 10:06:53 2023 +0200 Cygwin: cygheap: fix fork error after heap has grown 2f9b8ff0 introduced a problem where forks would sometimes fail with: child_copy: cygheap read copy failed, 0x0..0x80044C750, done 0, windows pid 14032, Win32 error 299 When cygheap_max was > CYGHEAP_STORAGE_INITIAL, commit_size would be set to allocsize(cygheap_max), which is an address, not a size. VirtualAlloc would be called to commit commit_size bytes, which would fail, and then child_copy would be called with zero as the base address. Fixes: 2f9b8ff00cce ("Cygwin: decouple cygheap from Cygwin DLL") Signed-off-by: David McFarland <corngood@gmail.com> Diff: --- winsup/cygwin/mm/cygheap.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/mm/cygheap.cc b/winsup/cygwin/mm/cygheap.cc index 6a20c159ab44..a20ee5972aed 100644 --- a/winsup/cygwin/mm/cygheap.cc +++ b/winsup/cygwin/mm/cygheap.cc @@ -87,7 +87,8 @@ cygheap_fixup_in_child (bool execed) SIZE_T commit_size = CYGHEAP_STORAGE_INITIAL - CYGHEAP_STORAGE_LOW; if (child_proc_info->cygheap_max > (void *) CYGHEAP_STORAGE_INITIAL) - commit_size = allocsize (child_proc_info->cygheap_max); + commit_size = allocsize ((char *) child_proc_info->cygheap_max + - CYGHEAP_STORAGE_LOW); cygheap = (init_cygheap *) VirtualAlloc ((LPVOID) CYGHEAP_STORAGE_LOW, CYGHEAP_STORAGE_HIGH - CYGHEAP_STORAGE_LOW,
reply other threads:[~2023-04-18 8:13 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=20230418081329.F148A3858412@sourceware.org \ --to=corinna@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: linkBe 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).