This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Initialising gnuwin DLLs


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 <stdio.h>
#include <windows.h>

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@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]