#1560: Windows CreateProcess quotes bug; make re-executing itself fails
--------------------------------+-------------------------------------------
  Reporter:  igloo              |          Owner:         
      Type:  bug                |         Status:  new    
  Priority:  high               |      Milestone:  6.8    
 Component:  libraries (other)  |        Version:  6.6.1  
  Severity:  normal             |       Keywords:         
Difficulty:  Unknown            |             Os:  Windows
  Testcase:                     |   Architecture:  Unknown
--------------------------------+-------------------------------------------
Something very odd is going on with the way we run other programs on
 Windows (msys/mingw).
 The following session shows that, regardless of whether or not we put
 quotes around the program we want to run when calling `CreateProcess`,
 there are no quotes in `argv[0]`. However, when make comes to reinvoke
 itself (after building any 'include'ed Makefiles) it has managed to find
 the quotes and fails to execute '"make"'.

 This should be fairly easy to debug, except I cannot build the make that
 it is using.
 The failure is shown even further down.

 The re-execution happens around line 1934 in the source I have:
 {{{
               char **p;
               fputs (_("Re-executing:"), stdout);
               for (p = nargv; *p != 0; ++p)
                 printf (" %s", *p);
               putchar ('\n');
 }}}

 If anyone can work out where the quotes come from, can make a small
 program that exhibits the same problem or has any idea what the problem
 with building make is, then please let me know!


 Thanks

 Ian

 {{{
 $ gcc --version
 gcc.exe (GCC) 3.4.2 (mingw-special)
 Copyright (C) 2004 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.

 $ make --version
 GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
 Built for i686-pc-msys
 Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
         Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.
 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
 PARTICULAR PURPOSE.

 Report bugs to <[EMAIL PROTECTED]>.

 $ cat Makefile

 .PHONY: foo
 foo:
         echo hello $(VAR) world
         rm -f include.Makefile

 include include.Makefile
 include.Makefile:
         echo "VAR=val" > $@

 $ cat show_args.c
 #include <stdio.h>

 int main(int argc, char *argv[]) {
     int i;
     printf("argc = %d\n", argc);
     for (i = 0; i < argc; i++) {
         printf("argv[%d] = %s\n", i, argv[i]);
     }
     return 0;
 }

 $ cat test.c
 #include <stdio.h>
 #include <windows.h>

 int foo(char *cmdline) {
     int r;
     int flags = 0;
     void *environment = NULL;
     void *workingDirectory = NULL;

     STARTUPINFO si;
     PROCESS_INFORMATION pi;

     ZeroMemory(&si, sizeof(si));
     si.cb = sizeof(si);
     ZeroMemory(&pi, sizeof(pi));

     printf("********************************************\n");
     printf("*** cmdline = %s\n", cmdline);
     fflush(stdout);
     r = CreateProcess(NULL, cmdline, NULL, NULL, TRUE, flags, environment,
 workingDirectory, &si, &pi);
     printf("*** r = %d\n", r);
     fflush(stdout);
     WaitForSingleObject(pi.hProcess, INFINITE);
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hThread);
 }

 int main(int argc, char *argv[]) {
     foo("./show_args a b c");
     foo("\"./show_args\" a b c");
     foo("make -dr");
     foo("\"make\" -dr");
     return 0;
 }

 $ gcc show_args.c -o show_args
 $ gcc test.c -o test
 $ ./test.exe
 ********************************************
 *** cmdline = ./show_args a b c
 *** r = 1
 argc = 4
 argv[0] = ./show_args
 argv[1] = a
 argv[2] = b
 argv[3] = c
 ********************************************
 *** cmdline = "./show_args" a b c
 *** r = 1
 argc = 4
 argv[0] = ./show_args
 argv[1] = a
 argv[2] = b
 argv[3] = c
 ********************************************
 *** cmdline = make -dr
 *** r = 1
 GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
 Built for i686-pc-msys
 Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
         Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.
 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
 PARTICULAR PURPOSE.

 Report bugs to <[EMAIL PROTECTED]>.

 Reading makefiles...
 Reading makefile `Makefile'...
 Reading makefile `include.Makefile' (search path) (no ~ expansion)...
 Makefile:7: include.Makefile: No such file or directory
 Updating makefiles....
  Considering target file `include.Makefile'.
   File `include.Makefile' does not exist.
   Finished prerequisites of target file `include.Makefile'.
  Must remake target `include.Makefile'.
 echo "VAR=val" > include.Makefile
 Putting child 0x0a0158b0 (include.Makefile) PID 2476 on the chain.
 Live child 0x0a0158b0 (include.Makefile) PID 2476
 Got a SIGCHLD; 1 unreaped children.
 Reaping winning child 0x0a0158b0 PID 2476
 Removing child 0x0a0158b0 PID 2476  from chain.
  Successfully remade target file `include.Makefile'.
  Considering target file `Makefile'.
   Looking for an implicit rule for `Makefile'.
   No implicit rule found for `Makefile'.
   Finished prerequisites of target file `Makefile'.
  No need to remake target `Makefile'.
 Re-executing: make -dr
 GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
 Built for i686-pc-msys
 Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
         Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.
 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
 PARTICULAR PURPOSE.

 Report bugs to <[EMAIL PROTECTED]>.

 Reading makefiles...
 Reading makefile `Makefile'...
 Reading makefile `include.Makefile' (search path) (no ~ expansion)...
 Updating makefiles....
  Considering target file `include.Makefile'.
   Finished prerequisites of target file `include.Makefile'.
  No need to remake target `include.Makefile'.
  Considering target file `Makefile'.
   Looking for an implicit rule for `Makefile'.
   No implicit rule found for `Makefile'.
   Finished prerequisites of target file `Makefile'.
  No need to remake target `Makefile'.
 Updating goal targets....
 Considering target file `foo'.
  File `foo' does not exist.
  Finished prerequisites of target file `foo'.
 Must remake target `foo'.
 echo hello val world
 Putting child 0x0a014348 (foo) PID 2160 on the chain.
 Live child 0x0a014348 (foo) PID 2160
 hello val world
 Got a SIGCHLD; 1 unreaped children.
 Reaping winning child 0x0a014348 PID 2160
 rm -f include.Makefile
 Live child 0x0a014348 (foo) PID 3428
 Got a SIGCHLD; 1 unreaped children.
 Reaping winning child 0x0a014348 PID 3428
 Removing child 0x0a014348 PID 3428  from chain.
 Successfully remade target file `foo'.
 ********************************************
 *** cmdline = "make" -dr
 *** r = 1
 GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
 Built for i686-pc-msys
 Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
         Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.
 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
 PARTICULAR PURPOSE.

 Report bugs to <[EMAIL PROTECTED]>.

 Reading makefiles...
 Reading makefile `Makefile'...
 Reading makefile `include.Makefile' (search path) (no ~ expansion)...
 Makefile:7: include.Makefile: No such file or directory
 Updating makefiles....
  Considering target file `include.Makefile'.
   File `include.Makefile' does not exist.
   Finished prerequisites of target file `include.Makefile'.
  Must remake target `include.Makefile'.
 echo "VAR=val" > include.Makefile
 Putting child 0x0a0158b0 (include.Makefile) PID 3972 on the chain.
 Live child 0x0a0158b0 (include.Makefile) PID 3972
 Got a SIGCHLD; 1 unreaped children.
 Reaping winning child 0x0a0158b0 PID 3972
 Removing child 0x0a0158b0 PID 3972  from chain.
  Successfully remade target file `include.Makefile'.
  Considering target file `Makefile'.
   Looking for an implicit rule for `Makefile'.
   No implicit rule found for `Makefile'.
   Finished prerequisites of target file `Makefile'.
  No need to remake target `Makefile'.
 Re-executing: "make" -dr
 "make": "make": Command not found

 $
 }}}

 {{{
 make  all-recursive
 make[1]: Entering directory `/home/ian/make/make-3.79.1-mingw'
 Making all in glob
 make[2]: Entering directory `/home/ian/make/make-3.79.1-mingw/glob'
 gcc -DHAVE_CONFIG_H -I. -I. -I..     -g -O2 -c glob.c
 glob.c:75:18: pwd.h: No such file or directory
 glob.c: In function `glob':
 glob.c:682: warning: assignment makes pointer from integer without a cast
 glob.c:685: error: dereferencing pointer to incomplete type
 glob.c:766: warning: assignment makes pointer from integer without a cast
 glob.c:769: error: dereferencing pointer to incomplete type
 make[2]: *** [glob.o] Error 1
 make[2]: Leaving directory `/home/ian/make/make-3.79.1-mingw/glob'
 make[1]: *** [all-recursive] Error 1
 make[1]: Leaving directory `/home/ian/make/make-3.79.1-mingw'
 make: *** [all-recursive-am] Error 2
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1560>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to