This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: Initialising gnuwin DLLs
- To: mbrett at wren dot rpms dot ac dot uk, pfay at acl dot lanl dot gov
- Subject: Re: Initialising gnuwin DLLs
- From: tvoverbe at wk dot estec dot esa dot nl (Ton van Overbeek)
- Date: Fri, 30 Jan 98 11:15:26 +0100
- 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@cygnus.com" with one line of text: "help".