delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/01/30/04:43:00

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: <Pine.SUN.3.91.980130102052.12961A-100000.cygnus.gnu-win32@jaguar>
References: <Pine DOT SGI DOT 3 DOT 96 DOT 980129233312 DOT 6403C-100000 AT bluemountain DOT acl DOT lanl DOT gov>
Mime-Version: 1.0
To: "Patrick J. Fay" <pfay AT acl DOT lanl DOT gov>
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 <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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019