This is the mail archive of the cygwin-developers@sourceware.cygnus.com 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]

Re: Can't execute Cygwin applications directly on cmd.exe


On Sun, May 21, 2000 at 06:40:38PM -0400, Chris Faylor wrote:
>On Mon, May 22, 2000 at 02:28:55AM +0900, Kazuhiro Fujieda wrote:
>>I can't execute Cygwin applications directly on the command
>>prompt (cmd.exe) as the following since 2000/05/16. I can
>>observe this problem only on NT4 Sp6a.
>>
>>Microsoft(R) Windows NT(R)
>>(C) Copyright 1985-1996 Microsoft Corp.
>>
>>C:\Home\fujieda>ls
>>C:\CYGWIN\USR\BIN\ls.exe: *** couldn't dynamically determine load address for 'NetWkstaUserGetInfo', Win32 error 127
>>
>>C:\Home\fujieda>
>>
>>It is triggered by the following modification in dcrt0.cc.
>>I confirmed it was solved by canceling the modification.
>
>Obviously this isn't a problem for me.  Can you tell me why moving an
>initialization routine three or four lines up causes this behavior?
>It makes no sense to me so there's no way I'll be able to debug it.

As usual, I figured it out two seconds after complaining.

There is and was a race due to the fact that uinfo_init can be called
twice, once by the wait_sig thread and once in dcrt0.cc.  It is just
sheer luck that this has never been triggered before.

My preference for fixing this would be to move the call to uinfo_init
prior to the call to sig_init.  I've checked in a change which does this.

Corinna, is there any reason why this is a bad idea?

cgf

Sun May 21 20:51:44 2000  Christopher Faylor <cgf@cygnus.com>

        * dcrt0.cc (dll_crt0_1): Move uinfo_init call to before sigproc_init to 
        avoid a race. 
        (noload): Add an extra argument for debugging.
        * uinfo.cc (uinfo_init): Eliminate test for multiple calls.
        (getlogin): Assume that uinfo_init has already been called.

Index: dcrt0.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dcrt0.cc,v
retrieving revision 1.16
diff -u -p -r1.16 dcrt0.cc
--- dcrt0.cc	2000/05/18 21:30:30	1.16
+++ dcrt0.cc	2000/05/22 00:51:12
@@ -721,6 +721,9 @@ dll_crt0_1 ()
   /* Allocate dtable */
   dtable_init ();
 
+/* Initialize uid, gid. */
+  uinfo_init ();
+
   /* Initialize signal/subprocess handling. */
   sigproc_init ();
 
@@ -730,11 +733,6 @@ dll_crt0_1 ()
   /* Set up standard fds in file descriptor table. */
   hinfo_init ();
 
-#if 0
-  /* Initialize uid, gid. */
-  uinfo_init ();
-#endif
-
   /* Scan the command line and build argv.  Expand wildcards if not
      called from another cygwin process. */
   build_argv (line, argv, argc,
@@ -758,14 +756,11 @@ dll_crt0_1 ()
   set_errno (0);
   debug_printf ("user_data->main %p", user_data->main);
 
-  /* Initialize uid, gid. */
-  uinfo_init ();
-
   /* Flush signals and ensure that signal thread is up and running. Can't
      do this for noncygwin case since the signal thread is blocked due to
      LoadLibrary serialization. */
   if (!dynamically_loaded)
-    sig_send (NULL, __SIGFLUSH);
+    sig_send (NULL, __SIGFLUSH);	/* also initializes uid, gid */
 
   if (user_data->main && !dynamically_loaded)
     exit (user_data->main (argc, argv, *user_data->envptr));
@@ -992,13 +987,14 @@ __api_fatal (const char *fmt, ...)
 }
 
 extern "C" {
-static void noload (char *s) __asm__ ("noload");
+static void noload (HANDLE h, char *s) __asm__ ("noload");
 static void __attribute__((unused))
-noload (char *s)
+noload (HANDLE h, char *s)
 {
-  api_fatal ("couldn't dynamically determine load address for '%s', %E", s);
+  api_fatal ("couldn't dynamically determine load address for '%s' (handle %p), %E", s, h);
 }
 
+/* FIXME: This is not thread-safe! */
 __asm__ ("
 .globl	cygwin_dll_func_load
 cygwin_dll_func_load:
@@ -1013,6 +1009,8 @@ cygwin_dll_func_load:
   popl %eax		# No.  Get back
   addl $8,%eax		#  pointer to name
   pushl %eax		#   and
+  movl -4(%eax),%eax	# Address of Handle to DLL
+  pushl (%eax)		# Handle to DLL
   call noload		#    issue an error
 gotit:
   popl %ecx		# Pointer to 'return address'
Index: uinfo.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/uinfo.cc,v
retrieving revision 1.2
diff -u -p -r1.2 uinfo.cc
--- uinfo.cc	2000/04/19 20:03:51	1.2
+++ uinfo.cc	2000/05/22 00:51:12
@@ -109,9 +109,6 @@ uinfo_init ()
 {
   struct passwd *p;
 
-  if (myself->username[0])
-    return;
-
   myself->psid = (PSID) myself->sidbuf;
   if ((p = getpwnam (internal_getlogin (myself))) != NULL)
     {
@@ -140,7 +137,6 @@ getlogin (void)
   static NO_COPY char this_username[MAX_USER_NAME];
 #endif
 
-  uinfo_init ();
   return strcpy (this_username, myself->username);
 }
 

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