Sorry,
Cygwin version: 2.9.0
OS: Windows 10
Arch: 64bit
The sample was also attached.
Le 09/12/2017 à 16:48, Andrey Repin a écrit :
Greetings, Stéphane Mbape!
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.
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdint.h>
#define MMAP_PROT (PROT_READ|PROT_WRITE)
#define MMAP_FLAGS_PROBE (MAP_PRIVATE|MAP_ANONYMOUS)
int main() {
printf("I am master %d\n", (int) getpid());
size_t size = ((size_t)128U * (size_t)1024U);
uintptr_t hint_addr = 0;
void *p = mmap((void *)hint_addr, size, MMAP_PROT, MMAP_FLAGS_PROBE, -1, 0);
printf ("nmap() = %p, hint_addr = %p\n", p, (void *) hint_addr);
uintptr_t addr = (uintptr_t) p;
munmap(p, size); // make sure there is an unmapped memory
// hint_addr = addr; // produces no error
hint_addr = addr + 1;
p = mmap((void *)hint_addr, size, MMAP_PROT, MMAP_FLAGS_PROBE, -1, 0);
printf ("nmap() = %p, hint_addr = %p\n", p, (void *) hint_addr);
pid_t child_pid = fork();
if (child_pid < 0) {
perror("fork failed");
} else if (child_pid == 0) {
printf("I am worker %d\n", (int) getpid());
sleep(2);
printf("worker exiting\n");
exit(0);
}
wait(NULL);
printf("master exiting\n");
return 0;
}
--
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