On Mon, 19 May 2025, Yuyi Wang via Cygwin wrote: > Recently I'm trying to build rustc on Cygwin (actually MSYS2). Here is the > error: > > 0 [main] rustc 3299 child_info_fork::abort: couldn't allocate memory > 0x1FD100000(0) for > '\??\D:\Straw\Documents\Git\rust\build\x86_64-pc-cygwin\stage1-rustc\release\deps\zerovec_derive-4b870d338ef8cbdd.dll' > alignment, Win32 error 87 > 0 [main] rustc 3299 child_info_fork::abort: couldn't allocate memory > 0x1FD100000(0) for > '\??\D:\Straw\Documents\Git\rust\build\x86_64-pc-cygwin\stage1-rustc\release\deps\zerovec_derive-4b870d338ef8cbdd.dll' > alignment, Win32 error 87 > error: could not exec the linker `x86_64-pc-msys-gcc` > > Seems that reserve_at() in file cygwin/winsup/cygwin/dll_init.cc is trying to > call > VirtualAlloc() with size == 0. That's why it returns 87 > (ERROR_INVALID_PARAMETER). > This error is rare and I'm not able to create an MWE now. > > I looked into the source code in dll_init.cc and confirmed that size is > possible > to be zero. I guess that end == dll_end in this case. (here != dll_base > because of > the conditions in callee.) So the dll straddles our left edge. Is this a bug > of > the code?
That doesn't make sense to me. It just loaded the DLL at `here`, but `here` != `dll_base`, so it unloaded it again and queried the address space where it just was. It seems impossible for the 'straddles our left edge' case to be hit *and* end == dll_end unless a) the dll has changed and is now smaller than it used to be, or b) mb.BaseAddress != `here`? c) some sort of race condition where the memory where the dll was just loaded is now not free at VirtualQuery time? BLODA? d) I'm missing something The only thing I can see that might potentially be a bug in the code is maybe size = mb.RegionSize - (here - mb.BaseAddress); but that seems extremely unlikely. Is there a possibility that the dll is getting replaced while a process that's running is still using it, which then subsequently forks? -- 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