Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid McFarland <corngood@gmail.com>2023-04-18 03:41:55 +0300
committerCorinna Vinschen <corinna@vinschen.de>2023-04-18 11:12:43 +0300
commit6fbca24f33c2430b51c5413a7b4c85f4784b4d4c (patch)
tree9ae31967a8be1414385914b150ed42f7eb5d0fde
parent595fcb21ffc01b3469dad6484c11ebfd263d7f3c (diff)
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>
-rw-r--r--winsup/cygwin/mm/cygheap.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/winsup/cygwin/mm/cygheap.cc b/winsup/cygwin/mm/cygheap.cc
index 609407656..4fda29d11 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,