From: David McFarland <corngood@gmail.com>
To: cygwin-developers@cygwin.com
Subject: Re: [PATCH] Cygwin: cygheap: fix fork error after heap has grown
Date: Thu, 13 Apr 2023 09:53:06 -0300 [thread overview]
Message-ID: <87fs946j0t.fsf@gmail.com> (raw)
In-Reply-To: <20230413023517.62725-1-corngood@gmail.com> (David McFarland's message of "Wed, 12 Apr 2023 23:35:17 -0300")
David McFarland <corngood@gmail.com> writes:
> 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.
> ---
> winsup/cygwin/mm/cygheap.cc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/winsup/cygwin/mm/cygheap.cc b/winsup/cygwin/mm/cygheap.cc
> index 6a20c159a..d614fc7a9 100644
> --- a/winsup/cygwin/mm/cygheap.cc
> +++ b/winsup/cygwin/mm/cygheap.cc
> @@ -87,7 +87,7 @@ 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 (child_proc_info->cygheap_max) - CYGHEAP_STORAGE_LOW;
> cygheap = (init_cygheap *) VirtualAlloc ((LPVOID) CYGHEAP_STORAGE_LOW,
> CYGHEAP_STORAGE_HIGH
> - CYGHEAP_STORAGE_LOW,
It might be better to do the subtraction before the call to allocsize,
but this should still work in practice. I'll wait for more feedback
before I post another patch.
next prev parent reply other threads:[~2023-04-13 12:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-13 2:35 David McFarland
2023-04-13 12:53 ` David McFarland [this message]
2023-04-13 16:16 ` Corinna Vinschen
2023-04-18 0:25 ` David McFarland
2023-04-18 0:41 ` David McFarland
2023-04-18 8:14 ` Corinna Vinschen
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=87fs946j0t.fsf@gmail.com \
--to=corngood@gmail.com \
--cc=cygwin-developers@cygwin.com \
/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).