X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:reply-to:subject:to:references:from:message-id
	:date:mime-version:in-reply-to:content-type
	:content-transfer-encoding; q=dns; s=default; b=egN/GF2vwsIazajl
	S3qkCsbq9+Owxt/jEN7/e0FlQtxl+L3ckqNjY5m4SatxV/Arve6l+zPNO1PYyasm
	FDiOah5G87ZnDR4pvDHPukyc8XjonYQogYe2CyT5llzoP3bJDku3pZR4hXSrvZeW
	U4po8Y0KHAETEu6/3mrMp+TfSVM=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:reply-to:subject:to:references:from:message-id
	:date:mime-version:in-reply-to:content-type
	:content-transfer-encoding; s=default; bh=8YNnhcdHTbTPUq8htx/fat
	FFNhc=; b=OiKOwdR0wE5/MQx562wPjnI1HjI0nU0bw1HwejLOqgdYoj7pzDeoEI
	fhtYKwP5bghTebH5rDoLPgNHyKF288PJok5kYverAjXO9snhG6RVL/jk3jTRQLkt
	tFMmUZ49Jzp9O3PA/oOw1vHY+qXfw4TUupJj7dkwue/1crDo3aZzE=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=Resource, calgary, H*Ad:D*ca, died
X-HELO: smtp-out-no.shaw.ca
X-Authority-Analysis: v=2.2 cv=KLEqNBNo c=1 sm=1 tr=0 a=MVEHjbUiAHxQW0jfcDq5EA==:117 a=MVEHjbUiAHxQW0jfcDq5EA==:17 a=N659UExz7-8A:10 a=oLqSD0wlW_gxLNe4lScA:9 a=ZDkxEcC2oR8UxKV5:21 a=4UhSNKlRJFXP1cvL:21 a=pILNOxqGKmIA:10
Reply-To: Brian.Inglis@SystematicSw.ab.ca
Subject: Re: fork fails after nmap with hint address in an unmapped memory region
To: cygwin@cygwin.com
References: <b431898c-30f5-2847-c922-0f25a525ef76@yahoo.fr> <15510444518.20171209184819@yandex.ru> <42c71a45-e61b-6917-b634-e912fb51d2d5@yahoo.fr>
From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
Message-ID: <56047a39-4e1e-fa50-0e8b-c123c5b5ed3c@SystematicSw.ab.ca>
Date: Sat, 9 Dec 2017 11:29:45 -0700
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0
MIME-Version: 1.0
In-Reply-To: <42c71a45-e61b-6917-b634-e912fb51d2d5@yahoo.fr>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 8bit
X-CMAE-Envelope: MS4wfDp/FnjHImBgXyQU0AX1ANgBb45FtSL19oHhF72iFIBlPrHk2d7YBgcbrfCO6V9B/EOveNrLuspyQwtyY6QMD7A8sz9aOFfXvfwmoDeK4es0e1mJ9DYd qFO5YOdC8jxDImsZK6jifEI49SrBDSY0gMN3NktX3lVRyu7yF8ehgiF6TW86PFrUft8o84FZWFOL+g==
X-IsSubscribed: yes

On 2017-12-09 08:53, Stéphane Mbape via cygwin wrote:
> Le 09/12/2017 à 16:48, Andrey Repin a écrit :
>>> While embeding luajit in a c  program, I found myself unable to fork
>>> processes.
>>> Investigations prove that it was related to nmap.
>>> To be accurate, calling nmap with hint address in a unmapped memory
>>> region will cause all forks to fail with
>>> "fixup_mmaps_after_fork: ReadProcessMemory failed for MAP_PRIVATE
>>> address 0x6FFFFFE0000, Win32 error 299"
>>> There is a sample code below.
>> You forgot to mention Cygwin version you're using, and please provide the
>> sample as an attach to save people the copy-pasting issues.
> Cygwin version: 2.9.0
> OS: Windows 10
> Arch: 64bit
> The sample was also attached.

Confirmed reproducible; addr2line does not give anything useful from the
stackdump, but included raw stackdump below, in case it gives hints.
Complete output after renaming doscript.c to mmap_fork_stc.c, also with addr +
4096 as well as addr + 1:

$ gcc -g -O0 -o mmap_fork_stc{,.c}
$ ./mmap_fork_stc
I am master 5464
nmap() = 0x6fffffe0000, hint_addr = 0x0
nmap() = 0x6fffffe0000, hint_addr = 0x6fffffe1000
      1 [main] mmap_fork_stc 11408 fixup_mmaps_after_fork: ReadProcessMemory
failed for MAP_PRIVATE address 0x6FFFFFE0000, Win32 error 299
    286 [main] mmap_fork_stc 11408 ...\mmap_fork_stc.exe: *** fatal error in
forked process - recreate_mmaps_after_fork_failed
   1298 [main] mmap_fork_stc 11408 cygwin_exception::open_stackdumpfile: Dumping
stack trace to mmap_fork_stc.exe.stackdump
      0 [main] mmap_fork_stc 5464 fork: child -1 - forked process 11408 died
unexpectedly, retry 0, exit code 0x100, errno 11
fork failed: Resource temporarily unavailable
master exiting
$ more mmap_fork_stc.exe.stackdump
Stack trace:
Frame        Function    Args
000005FF3A0  0018005CD8E (0018021AE80, 0018021AC46, 00000008000, 000005FB010)
000005FF3A0  001800465F9 (000005FDDE0, 000005FF3A0, 001800B2D10, 00000000000)
000005FF3A0  00180046632 (00000000000, 000005FBE28, 00000008000, 00100402068)
000005FF3A0  00180046B84 (0007FFE0385, 000005FDDE0, 001800B2D10, 00000000000)
000005FF3A0  00180048040 (00000000000, 00000000000, 00000000000, 00000000000)
000005FF3A0  001800B2EDB (00000000000, 00000000000, 00000000000, 00000000000)
000005FF620  7FFF7777485F (00180040000, 00000000001, 00000240022, 000006D20C8)
000005FF620  7FFF7779D762 (7FFF77797900, 000006D2701, 7FFF774A27BA, 000006D2F10)
000005FF620  7FFF7779D5AB (000006D2720, 000005FF5D0, 00000000003, 0000032E000)
000005FF620  7FFF7779D5D1 (00000000003, 000005FF629, 00000000003, 00000000000)
00000000000  7FFF777E1D31 (00000000000, 00000000000, 00000000001, 00000000000)
00000000000  7FFF7781A1FC (00000000000, 00000000000, 0000032E000, 00000000000)
00000000000  7FFF777C9B1B (00000000000, 00000000000, 00000000000, 00000000000)
00000000000  7FFF777C9ACE (00000000000, 00000000000, 00000000000, 00000000000)
End of stack trace
$ cygcheck ./mmap_fork_stc
C:\Users\bwi\src\cygwin\mmap_fork_stc.exe
  C:\usr\local\cygwin64\bin\cygwin1.dll
    C:\WINDOWS\system32\KERNEL32.dll
      C:\WINDOWS\system32\ntdll.dll
      C:\WINDOWS\system32\KERNELBASE.dll
      C:\Program Files\TortoiseGit\bin\api-ms-win-core-handle-l1-1-0.dll
      C:\WINDOWS\system32\api-ms-win-core-synch-l1-2-0.dll
      C:\WINDOWS\system32\api-ms-win-core-timezone-l1-1-0.dll
      C:\Program Files\TortoiseGit\bin\api-ms-win-core-string-l1-1-0.dll
      C:\Program Files\TortoiseGit\bin\api-ms-win-core-util-l1-1-0.dll
      C:\Program Files\TortoiseGit\bin\api-ms-win-core-profile-l1-1-0.dll
      C:\WINDOWS\system32\api-ms-win-core-xstate-l2-1-0.dll
      C:\Program Files\TortoiseGit\bin\api-ms-win-core-console-l1-1-0.dll
$ cmd /c ver

Microsoft Windows [Version 10.0.15063]
$ uname -srvmo
CYGWIN_NT-10.0 2.9.0(0.318/5/3) 2017-09-12 10:18 x86_64 Cygwin

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

