Hi Cygwin developers,
I'm writing to report a fatal crash that occurs on Windows 11 x64 with
a self-compiled program, but does NOT occur on Windows 10 x64 or
Windows 11 ARM.
## Symptom
A self-compiled program terminates immediately at startup with:
*** fatal error - MapViewOfFileEx 'cygpid.XXXXXX'(0x46C, size 64896,
m 6, created 0), Win32 error 487. Terminating.
Hangup
Win32 error 487 is ERROR_INVALID_ADDRESS, meaning the target virtual
address is already occupied at the time of mapping.
## Root Cause Analysis
After reading the Cygwin source code, I traced the crash to
winsup/cygwin/shared.cc, inside open_shared():
static NO_COPY uintptr_t next_address = SHARED_REGIONS_ADDRESS_LOW;
do {
addr = (void *) next_address;
shared = MapViewOfFileEx(shared_h, access, 0, 0, 0, addr);
next_address += wincap.allocation_granularity();
if (next_address >= SHARED_REGIONS_ADDRESS_HIGH) {
if (!shared && loop) break; // exhausted
entire range -> api_fatal
next_address = SHARED_REGIONS_ADDRESS_LOW;
loop = true;
}
} while (!shared);
The address range is defined in winsup/cygwin/memory_layout.h:
#define SHARED_REGIONS_ADDRESS_LOW 0x1a0000000UL
#define SHARED_REGIONS_ADDRESS_HIGH 0x200000000UL
On my Windows 11 x64 system, every MapViewOfFileEx() call in the loop
fails with ERROR_INVALID_ADDRESS (487) for this particular program,
exhausting the entire range and triggering the api_fatal().
I used VirtualQuery() to scan the address space and confirmed that the
0x1a0000000-0x200000000 range is occupied when this program runs.
The exact cause of the occupation is not yet identified, but it is
reproducibly absent on Windows 10 x64 and Windows 11 ARM.
## Workaround (user-side)
I confirmed a fix by patching the two constants in cygwin1.dll to:
SHARED_REGIONS_ADDRESS_LOW = 0x140000000
SHARED_REGIONS_ADDRESS_HIGH = 0x1a0000000
The new range was verified free via VirtualQuery(), and the program
runs normally after the patch.
## Suggested Fix
It may be worth investigating why the 0x1a0000000-0x200000000 range
becomes unavailable on Windows 11 x64 in certain scenarios, and
considering whether the range defined in memory_layout.h should be
adjusted or made more resilient (e.g., falling back to a different
range instead of calling api_fatal).
## Environment
- Affected: Windows 11 x64 (tested on 25H2)
- Not affected: Windows 10 x64, Windows 11 ARM
- Cygwin: 3.6.7
I hope this analysis is useful. Happy to provide additional information
or run further diagnostics if needed.
Best regards
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple