Cygwin: fix initializing MEM_EXTENDED_PARAMETER

MEM_EXTENDED_PARAMETER consists of a 64 bit bitfield which contains
the Type and the Reserved members.  The former usage of designated
initializer lists initialized Type, but not Reserved.  Since that's
not possible anymore due to a g++ 11.2 bug, Cygwin initializes the
MEM_EXTENDED_PARAMETER structs explicitely.  This results in a
random value in Reserved, which at least VirtualAlloc2 chokes on
(ERROR_INVALID_PARAMETER).

Set Reserved explicitely to 0 for a fix.

Fixes: bdb7991db3 ("Cygwin: workaround a g++ 11.2 initialization bug")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2021-09-06 20:15:43 +02:00
parent eeeb5650cf
commit 3d322ac930
2 changed files with 4 additions and 0 deletions

View File

@ -519,6 +519,7 @@ class thread_allocator
/* g++ 11.2 workaround: don't use initializer */
MEM_EXTENDED_PARAMETER thread_ext;
thread_ext.Type = MemExtendedParameterAddressRequirements;
thread_ext.Reserved = 0;
thread_ext.Pointer = (PVOID) &thread_req;
SIZE_T real_size = roundup2 (size, THREAD_STACK_SLOT);
@ -540,6 +541,7 @@ class thread_allocator
/* g++ 11.2 workaround: don't use initializer */
MEM_EXTENDED_PARAMETER mmap_ext;
mmap_ext.Type = MemExtendedParameterAddressRequirements;
mmap_ext.Reserved = 0;
mmap_ext.Pointer = (PVOID) &mmap_req;
real_stackaddr = VirtualAlloc2 (GetCurrentProcess(), NULL, real_size,

View File

@ -209,6 +209,7 @@ MapView (HANDLE h, void *addr, size_t len, DWORD openflags,
/* g++ 11.2 workaround: don't use initializer */
MEM_EXTENDED_PARAMETER mmap_ext;
mmap_ext.Type = MemExtendedParameterAddressRequirements;
mmap_ext.Reserved = 0;
mmap_ext.Pointer = (PVOID) &mmap_req;
alloc_type |= attached (prot) ? MEM_RESERVE : 0;
@ -1629,6 +1630,7 @@ fhandler_dev_zero::mmap (caddr_t *addr, size_t len, int prot,
/* g++ 11.2 workaround: don't use initializer */
MEM_EXTENDED_PARAMETER mmap_ext;
mmap_ext.Type = MemExtendedParameterAddressRequirements;
mmap_ext.Reserved = 0;
mmap_ext.Pointer = (PVOID) &mmap_req;
base = VirtualAlloc2 (GetCurrentProcess(), *addr, len, alloc_type,