From: tvoverbe AT wk DOT estec DOT esa DOT nl (Ton van Overbeek) Subject: Re: Initialising gnuwin DLLs 30 Jan 1998 05:52:04 -0800 Message-ID: <9801301015.AA29684.cygnus.gnu-win32@wk.estec.esa.nl> To: mbrett AT wren DOT rpms DOT ac DOT uk, 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, sos AT buggy DOT prospect DOT com DOT ru 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. Your thread-safeness argument is certainly valid, but before that there are a lot of other things which need to be done. The scenario we are talking about is for writing a dll (say sample.dll) to be used with a non cygwin compiled application (e.g with a MS Visual C++, or as extension of an existing application (Matlab for example)). The sample.dll will also pull in cygwin.dll when it is compiled with the cygnus gnu-win32 compiler. When you do thing like disk file I/O, malloc() or getenv() in sample.dll it crashes. The reason for this is that cygwin.dll is not initialised. In a cygnus gnu-win32 compiled application this is done by the C runtime startup code. I started looking at the dll_crt0_1 routine in the winsup source of the latest Coolview. dll_crt0_1 is the part of the runtime startup done in cygwin.dll. A lot of things are done there: initialisation of heap (needed by malloc() and friends), initialisation of file I/O (connecting to Win32 filemap), etc. All these inits are not done in our scenario. It is a pity that all these init routines are not in the exported interface of cygwin.dll, so I do not know (yet) how to do them from our sample.dll. Any pointers (which inits are really necessary ?) from people in the know (Sergey ?) Ton van Overbeek. - 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".