Web lists-archives.com

Re: fork fails after nmap with hint address in an unmapped memory region




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