From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id E73623857036; Mon, 6 Sep 2021 18:29:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E73623857036 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: fix initializing MEM_EXTENDED_PARAMETER X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: eeeb5650cf706f4dde72ce8b8598aef41f88718a X-Git-Newrev: 3d322ac930ca6d2516680fc78e3d3018cc737483 Message-Id: <20210906182948.E73623857036@sourceware.org> Date: Mon, 6 Sep 2021 18:29:48 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2021 18:29:49 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3d322ac930ca6d2516680fc78e3d3018cc737483 commit 3d322ac930ca6d2516680fc78e3d3018cc737483 Author: Corinna Vinschen Date: Mon Sep 6 20:15:43 2021 +0200 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: bdb7991db38b ("Cygwin: workaround a g++ 11.2 initialization bug") Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/miscfuncs.cc | 2 ++ winsup/cygwin/mmap.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index f4c3a1c48..b544e7125 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -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, diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc index 69c8c8990..2e202a047 100644 --- a/winsup/cygwin/mmap.cc +++ b/winsup/cygwin/mmap.cc @@ -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,