This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cygpath hangings

On Tue, 14 Oct 2003, Brian Ford wrote:

> On Tue, 14 Oct 2003, Igor Pechtchanski wrote:
> >Brian Ford wrote:
> > > There will be no ouput unless main calls foo, right?
> >
> > Actually, if the DLL was loaded, there should be output even if foo isn't
> > called...
> >
> Just linking to it causes a load, or is it the first referance?  I'm a DLL
> dunce.

I've just verified that the DLL is loaded even if no functions from it are
called (or variables referenced).  FWIW, here's the code I used:

$ cat > cpath.c
int hello();
void foo (void) { hello(); }
int main (int argc, char **argv) { return 0; }
$ cat > cygx.c
#include <windows.h>
#include <stdio.h>

static int counter = 0;
static FILE *output = NULL;

int hello() {
  fprintf (output, "Hello world for the %dth time!\n", counter);
  fflush (output);
  return counter++;

  if (!output) output = fopen("cygx.out", "wt");
  fprintf (output, "DLL loaded: ");
  switch (f) {
    case DLL_PROCESS_ATTACH: fprintf (output, "process attach");
    case DLL_THREAD_ATTACH:  fprintf (output, "thread attach");
    case DLL_THREAD_DETACH:  fprintf (output, "thread detach");
    case DLL_PROCESS_DETACH: fprintf (output, "process detach");
    default:                 fprintf (output, "WTF?!");
  fprintf (output, "\n");
  fflush (output);
  return TRUE;
$ gcc -mno-cygwin -shared -o cygx.dll cygx.c
$ gcc -o cpath.exe cpath.c -L. -lcygx
$ ./cpath.exe; cat cygx.out
DLL loaded: process attach
DLL loaded: thread attach
DLL loaded: process detach

> > > Then, I still get a hang under setup from explorer; no output.
> >
> > This could be because the DLL was not loaded, or because of the two stdio
> > conflicts...  Did you compile the DLL with -mno-cygwin?
> No.  I guess you wanted me too? :)

I don't know if it matters, frankly.  It looks like the DLL is loaded, but
it doesn't load completely.  Maybe something that SHLWAPI.DLL is doing on

> > > Stand alone in a shell, output is:
> > >
> > > DLL loaded: process attach
> > > DLL loaded: thread attach
> > > Segmentation fault (core dumped)
> > >
> > > The SEGV is expected given the code is invalid anyway.
> > >
> > > Nothing to see here... move along...
> > > [snip test_dll.c]
> >
> > Hmm.  Maybe if the DLL has exported global variables, not just functions?
> > I'll see if I can come up with the appropriate code and will then post it
> > to the list.
> >
> Not following, but ok.

I meant making "counter" in the above example global rather than static.
Turns out it doesn't make a difference -- the DLL is loaded anyway.  I
still suspect the initialization code in SHLWAPI.DLL is doing something
that Cygwin doesn't like.
      |\      _,,,---,,_
ZZZzz /,`.-'`'    -.  ;-;;,_
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]