From: pfay@acl.lanl.gov (Patrick J. Fay)
Subject: Re: Initialising gnuwin DLLs
30 Jan 1998 03:02:18 -0800
Message-ID: <Pine.SGI.3.96.980129233312.6403C-100000.cygnus.gnu-win32@bluemountain.acl.lanl.gov>
References: <199801281358.NAA07920@magpie.rpms.ac.uk>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
To: Matthew Brett <mbrett@wren.rpms.ac.uk>
Cc: gnu-win32@cygnus.com, juerg.tschirren@isbe.ch, r_urbin1@ridgecrest.ca.us,
        tvoverbe@wk.estec.esa.nl

Hello Matthew,
I'm just guessing but it sounds like you are running into things that
are not thread-safe. You can allow on one thread into a code section
at a time with:
#include <stdio.h>
#include <windows.h>
CRITICAL_SECTION cs;
int main()
{
  int i;
  InitializeCriticalSection (&cs);
  EnterCriticalSection (&cs);
  printf("hello\n");
  LeaveCriticalSection (&cs);
  DeleteCriticalSection (&cs);
  return 0;
}

My guess is that, say, thread 1's printf calls malloc while
another thread is in malloc. What happens? who knows.
Pat
On Wed, 28 Jan 1998, Matthew Brett wrote:

> Dear All,
> 
> >From some recent messages, it looks as though several of us are having 
> difficulty using gnuwin DLLs with other software (such as VC++, matlab).
> Even something as innocent as a printf() command in the DLL causes 
> a memory access crash, with errors like:
> 
> The instruction at 0x1000c4ec referenced memory at 0x00000058
> 
> It's the same with many other functions: any file access function, malloc,
> pid, to name a random selection.  However, although malloc() causes a 
> crash, LocalAlloc does not.  I / we were wondering whether this was a DLL
> initialisation problem, and whether anyone knows how to initialise a
> gnuwin DLL properly for use by non-gnuwin apps.
> 
> Thanks for any help to the lost,
> 
> Matthew Brett
> 
> -
> For help on using this list (especially unsubscribing), send a message to
> "gnu-win32-request@cygnus.com" with one line of text: "help".
> 

Patrick Fay, Ph.D., Intel Corp.            email:   pfay@co.intel.com
Los Alamos National Lab                    wk:         (505) 665-9141
CTI M.S. B296                              fax:        (505) 667-5921
Los Alamos NM 87545    ASCI-RED http://www.acl.lanl.gov/~pfay/teraflop

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
