Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com X-Sent: 23 May 2001 19:20:00 GMT From: "Andrew de Quincey" To: "Robert Collins" , Subject: RE: Strange fork() behaviour under cygwin v1.3.1 Date: Wed, 23 May 2001 20:06:50 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 In-Reply-To: To recap, the program which is causing problems is: > #include > > void *test(void *arg); > > int main(int argc, char* argv[]) { > int pid; > pth_init(); > > pth_join(pth_spawn(PTH_ATTR_DEFAULT, test, NULL), NULL); > } > > void *test(void *arg) { > int pid; > > pid = fork(); > if (pid < 0) { > printf("FORKFAILED\n"); > } else if (pid == 0) { > printf("FORKCHILD\n"); > } else { > printf("FORKPARENT\n"); > } > } Running under gnu pth 1.4.0, and cygwin 1.3.2 > > -----Original Message----- > > From: Andrew de Quincey [mailto:andrew AT orbital DOT co DOT uk] > > > Rob wrote > > > > -----Original Message----- > > > > From: Andrew de Quincey [mailto:andrew AT orbital DOT co DOT uk] > > > > Hi, I've been playing with the jabber server under win32... > > > > and I've run > > > > into a slight problem. The following program illustrates it: > > > > > > > > > From the "non-preemptive-ness" & the lack of any pthread or > > win32 thread > > functions in it, it sounds like an entirely user-space > > threading library. > > Oh. Well I suggest you build a debug pth library, and optionally a debug > cygwin library (see the cvs source web page for build instructions), and > see if pth is doing funky stuff that might confuse fork(). If no actual > threads are involved, there shouldn't be any particular problems :]. > Also update to cygwin 1.3.2 just-in-case. OK, I am now using 1.3.2 (which didn't help :( I've investigated gnu pth a bit more, and it does do some "interesting" things with the stack when you spawn a new thread (I suppose it would have to). Could this be confusing cygwin? I've got cygwin compiled and put tracing statements in it. A more complete error output from the program is: C:\tmp\tmp\install\bin\test.exe: *** 1. unable to allocate heap 0xA010000, heap_chunk_size 268435456, pid 1568, Win32 error 487 0 [main] test 1516 sync_with_child: child 1568(0xB4) died before initialization with status code 0x1 252 [main] test 1516 sync_with_child: *** child state waiting for longjmp FORKFAILED The problem is coming from the DLL init code in dctr0.cc. A rough trace to the error is: dll_crt0_1() memory_init() heap_init() The error occurs in heap_init() in heap.cc.. in the following: char *p; for (;;) { p = (char *) VirtualAlloc (brkbase, reserve_size, MEM_RESERVE, PAGE_READWRITE); if (p) break; if ((reserve_size -= page_const) <= allocsize) break; } The VirtualAlloc just returns an error code, 487, which I believe is "Attempt to access invalid address. " As to *why* this is, I have no ideas.. can anyone help? -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple