DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 54JJcl6I2189552 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 54JJcl6I2189552 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=XDPTq52f X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2B473858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1747683525; bh=OZOfh/zjpCFOhfnr+wWp5WLi2rmccP+A0/FslE62IPo=; h=Date:To:cc:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=XDPTq52flJ+QLBnlPksLUVkgHJbqKl/n+lnByg7fNTJDYYDupL/4ZhOyt2h96dgjI tW7DyagYYt5GK6ooBkv+2YrKQ6YLjqBDPTYV+IOWWaB4pfILWXW1jyZ0dfY5NBbEGZ Zoidt4QrPMIhEOtHW3PwNMU9/c22Fpoh2awNwAUs= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9A733858D37 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B9A733858D37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747683462; cv=none; b=KOOd01MYJJf/yOI14lFkTboWWwGd2NAY18o1fWiBG7ZdzLBhabE1oxNRo8XfyCr/HWlaYWWsapUhjMS5p2+lpG0toMj5+SUHFFrW5rk47DJPOmtcin5I76WL9fbWB22SSt/ulSvap8wX+oG/x4V/h4II0EXBL/MCAr56XUvyVNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747683462; c=relaxed/simple; bh=KujdZk0VHx8TwQcY9C7TtEQ1YeUtcvuaALmgDnnuJFc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Rj6Nl7OndRyBI28K8XU8XxSGxLFn0mGDZs3YW6BDMJd+KCFD9u6Ejz0XcLcMmy0o6BsNe3ynAkaAxfZ7gXKzbQ0UjDkmqUMYF+sSM7dAnOGrxAMfnxnUaihj08QIgsirSsF2+yatenp2+13SLqGPkFaZXIaUZKN7QCSk372VuiY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B9A733858D37 Date: Mon, 19 May 2025 12:37:42 -0700 (PDT) X-X-Sender: jeremyd AT resin DOT csoft DOT net To: Yuyi Wang cc: cygwin AT cygwin DOT com Subject: Re: fork error when trying to call VirtualAlloc with size==0 In-Reply-To: Message-ID: <9635a215-9e5a-e725-cbe1-595f508032f6@jdrake.com> References: MIME-Version: 1.0 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jeremy Drake via Cygwin Reply-To: Jeremy Drake Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" 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