From: mbrett AT wren DOT rpms DOT ac DOT uk (Matthew Brett) Subject: Re: Initialising gnuwin DLLs 30 Jan 1998 04:43:00 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII To: "Patrick J. Fay" Cc: gnu-win32 AT cygnus DOT com, juerg DOT tschirren AT isbe DOT ch, r_urbin1 AT ridgecrest DOT ca DOT us, tvoverbe AT wk DOT estec DOT esa DOT nl Patrick Fay wrote: > I'm just guessing but it sounds like you are running into things that > are not thread-safe. > ..... > My guess is that, say, thread 1's printf calls malloc while > another thread is in malloc. What happens? who knows. Dear Patrick, Thanks a lot for your message. I went and tried it straightaway, but sadly, it didn't work. I compiled the DLL from the code below, and as before, this is fine when called by a gnuwin program, but crashes if linked to from VC++. Again, it works fine in VC++ if VC++ compiles the DLL. Actually, I had thought that code from a DLL called by the main application thread is contained in that thread. Is that wrong? It looks like Ton Van Overbeek has looked into this in much more detail then I have, and like him, I still think that the problem is that Cygwin.dll needs some initialisation which is not provided for DLLs. It would certainly fit with what we are getting... Cheers, Matthew ------------> the DLL I tried <----------------- /* vcdll.c */ #include #include CRITICAL_SECTION cs; int dll_func() { int i; InitializeCriticalSection (&cs); EnterCriticalSection (&cs); printf("hello\n"); LeaveCriticalSection (&cs); DeleteCriticalSection (&cs); return 42; } - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".