Subject: Re: Initialising gnuwin DLLs
From: [email-masked] (Matthew Brett)

30 Jan 1998 04:43:00 -0800
Message-ID: <Pine.SUN.3.91.980130102052.12961A-100000.cygnus.gnu-win32@jaguar>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
To: "Patrick J. Fay" <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked],
        [email-masked]

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
"[email-masked]" with one line of text: "help".