X-Recipient: archive-cygwin AT delorie DOT 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:from:reply-to:subject:to:message-id:date :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=NVfFHR4USnuNBZinkXiQ26Ty1TFi7ebuBSVo3DhY5A+UJBAV8Ds2i EzGUuooNR3JmNKuvMuBUJRAQmjTSeHbwUZCCP30mXgb/kLXxDsyuvDtKFJnec04l N/Vtk1a3IkO5HkeNLoMRrx3RjGHhO57eskxpG+b88dqYJZ/OfylvG8= 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:from:reply-to:subject:to:message-id:date :mime-version:content-type:content-transfer-encoding; s=default; bh=vIxMfRJtNTLp4rxYZrdl5XrPKsk=; b=KO/ucQOkj887DjEdYpXQYbhgiJ/v giWh4r7qz1M9wQkyM69Tv8xG5WG1FksDmWKBW9xt1RYIm++PXquxdgA/TStFwWEb 9trGLU4i/9ES88Hnc8hw2mh9xQT8ukmHl8Iy2l/0YL/woTvGfNP7RGQik2OhHMeo Vu4r51oXtuRC8uE= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=investigations, H*MI:30f5, UD:yahoo.fr, H*RU:77.238.176.206 X-HELO: sonic306-20.consmr.mail.ir2.yahoo.com From: "Stéphane Mbape via cygwin" Reply-To: =?UTF-8?Q?St=c3=a9phane_Mbape?= Subject: fork fails after nmap with hint address in an unmapped memory region To: cygwin AT cygwin DOT com Message-ID: Date: Sat, 9 Dec 2017 15:58:14 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Note-from-DJ: This may be spam Hello, 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. Thank you for reading. #include #include #include #include #include #include #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