make-w32
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interrupt/Exception caught (code = 0xc0000005, addr = 0x77c478ac)


From: Eli Zaretskii
Subject: Re: Interrupt/Exception caught (code = 0xc0000005, addr = 0x77c478ac)
Date: Thu, 03 Sep 2009 20:43:08 +0300

> Date: Tue, 1 Sep 2009 18:21:43 -0400
> From: Chris Sutcliffe <address@hidden>
> Cc: address@hidden
> 
> >> Are there any other patches that should be included?
> >
> > When was the previous build made?  If you tell me the date, I can look
> > for bugs fixed since then, and send the patches to you.
> 
> The last patch included in the previous binary was:
> 
> 2008-03-03  Eli Zaretskii  <address@hidden>

I have these patches since then:

2009-03-14  Eli Zaretskii  <address@hidden>

        * w32/pathstuff.c (convert_Path_to_windows32): Fix last change.
        Fixes Savannah bug #25412.

        * w32/subproc/sub_proc.c <top level>: Update Copyright years.  Add
        prototype for xmalloc.
        (find_file): Accept 3 arguments PATH_VAR, FULL_FNAME, and FULL_LEN
        instead of an LPOFSTRUCT pointer.  Use xmalloc instead of malloc.
        Loop over an array of extensions, instead of duplicating the same
        code inline.  Use SearchPath followed by CreateFile, instead of
        the obsolete OpenFile.  Fixes Savannah bug #17277.
        (process_begin): Find $(PATH) in `envp', and pass a pointer to it
        to `find_file'.  Fixes Savannah bug #25662.

2009-03-07  Eli Zaretskii  <address@hidden>

        * function.c (func_shell): Don't close pipedes[1] if it is -1.
        Fixes Savannah bug #20495.


--- function.c~ 2007-07-21 16:22:48.126125000 +0300
+++ function.c  2009-03-07 19:21:40.930500000 +0200
@@ -1700,7 +1700,8 @@ func_shell (char *o, char **argv, const 
       free ((char *) command_argv);
 
       /* Close the write side of the pipe.  */
-      (void) close (pipedes[1]);
+      if (pipedes[1] >= 0)
+       (void) close (pipedes[1]);
 #endif
 
       /* Set up and read from the pipe.  */


--- w32/subproc/sub_proc.c~0    2006-03-10 06:20:46.000000000 +0200
+++ w32/subproc/sub_proc.c      2009-03-14 16:32:08.593750000 +0200
@@ -1,6 +1,6 @@
 /* Process handling for Windows.
 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-2006 Free Software Foundation, Inc.
+              2006, 2009 Free Software Foundation, Inc.
 This file is part of GNU Make.
 
 GNU Make is free software; you can redistribute it and/or modify it under the
@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth 
 #include "debug.h"
 
 static char *make_command_line(char *shell_name, char *exec_path, char **argv);
+extern char *xmalloc (unsigned int);
 
 typedef struct sub_process_t {
        int sv_stdin[2];
@@ -347,53 +348,54 @@ process_init_fd(HANDLE stdinh, HANDLE st
 
 
 static HANDLE
-find_file(char *exec_path, LPOFSTRUCT file_info)
+find_file(const char *exec_path, const char *path_var,
+         char *full_fname, DWORD full_len)
 {
        HANDLE exec_handle;
        char *fname;
        char *ext;
+       DWORD req_len;
+       int i;
+       static const char *extensions[] =
+         /* Should .com come before no-extension case?  */
+         { ".exe", ".cmd", ".bat", "", ".com", NULL };
 
-       fname = malloc(strlen(exec_path) + 5);
+       fname = xmalloc(strlen(exec_path) + 5);
        strcpy(fname, exec_path);
        ext = fname + strlen(fname);
 
-       strcpy(ext, ".exe");
-       if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
-                       OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
-               free(fname);
-               return(exec_handle);
-       }
-
-       strcpy(ext, ".cmd");
-       if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
-                       OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
-               free(fname);
-               return(exec_handle);
-       }
-
-       strcpy(ext, ".bat");
-       if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
-                       OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
-               free(fname);
-               return(exec_handle);
-       }
-
-       /* should .com come before this case? */
-       if ((exec_handle = (HANDLE)OpenFile(exec_path, file_info,
-                       OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
-               free(fname);
-               return(exec_handle);
-       }
-
-       strcpy(ext, ".com");
-       if ((exec_handle = (HANDLE)OpenFile(fname, file_info,
-                       OF_READ | OF_SHARE_COMPAT)) != (HANDLE)HFILE_ERROR) {
-               free(fname);
-               return(exec_handle);
+       for (i = 0; extensions[i]; i++) {
+               strcpy(ext, extensions[i]);
+               if (((req_len = SearchPath (path_var, fname, NULL, full_len,
+                                           full_fname, NULL)) > 0
+                    /* For compatibility with previous code, which
+                       used OpenFile, and with Windows operation in
+                       general, also look in various default
+                       locations, such as Windows directory and
+                       Windows System directory.  Warning: this also
+                       searches PATH in the Make's environment, which
+                       might not be what the Makefile wants, but it
+                       seems to be OK as a fallback, after the
+                       previous SearchPath failed to find on child's
+                       PATH.  */
+                    || (req_len = SearchPath (NULL, fname, NULL, full_len,
+                                              full_fname, NULL)) > 0)
+                   && req_len <= full_len
+                   && (exec_handle =
+                               CreateFile(full_fname,
+                                          GENERIC_READ,
+                                          FILE_SHARE_READ | FILE_SHARE_WRITE,
+                                          NULL,
+                                          OPEN_EXISTING,
+                                          FILE_ATTRIBUTE_NORMAL,
+                                          NULL)) != INVALID_HANDLE_VALUE) {
+                       free(fname);
+                       return(exec_handle);
+               }
        }
 
        free(fname);
-       return(exec_handle);
+       return INVALID_HANDLE_VALUE;
 }
 
 
@@ -416,6 +418,9 @@ process_begin(
        char *shell_name = 0;
        int file_not_found=0;
        HANDLE exec_handle;
+       char exec_fname[MAX_PATH];
+       const char *path_var = NULL;
+       char **ep;
        char buf[256];
        DWORD bytes_returned;
        DWORD flags;
@@ -423,8 +428,6 @@ process_begin(
        STARTUPINFO startInfo;
        PROCESS_INFORMATION procInfo;
        char *envblk=NULL;
-       OFSTRUCT file_info;
-
 
        /*
         *  Shell script detection...  if the exec_path starts with #! then
@@ -433,16 +436,26 @@ process_begin(
         *  hard-code the path to the shell or perl or whatever:  Instead, we
         *  assume it's in the path somewhere (generally, the NT tools
         *  bin directory)
-        *  We use OpenFile here because it is capable of searching the Path.
         */
 
-       exec_handle = find_file(exec_path, &file_info);
+       /* Use the Makefile's value of PATH to look for the program to
+          execute, because it could be different from Make's PATH
+          (e.g., if the target sets its own value.  */
+       for (ep = envp; ep; ep++) {
+               if (strncmp (*ep, "PATH=", 5) == 0
+                   || strncmp (*ep, "Path=", 5) == 0) {
+                       path_var = *ep + 5;
+                       break;
+               }
+       }
+       exec_handle = find_file(exec_path, path_var,
+                               exec_fname, sizeof(exec_fname));
 
        /*
-        * If we couldn't open the file, just assume that Windows32 will be able
-        * to find and execute it.
+        * If we couldn't open the file, just assume that Windows will be
+        * somehow able to find and execute it.
         */
-       if (exec_handle == (HANDLE)HFILE_ERROR) {
+       if (exec_handle == INVALID_HANDLE_VALUE) {
                file_not_found++;
        }
        else {
@@ -496,8 +509,7 @@ process_begin(
        if (file_not_found)
                command_line = make_command_line( shell_name, exec_path, argv);
        else
-               command_line = make_command_line( shell_name, 
file_info.szPathName,
-                                argv);
+               command_line = make_command_line( shell_name, exec_fname, argv);
 
        if ( command_line == NULL ) {
                pproc->last_err = 0;
@@ -517,7 +529,7 @@ process_begin(
        if ((shell_name) || (file_not_found)) {
                exec_path = 0;  /* Search for the program in %Path% */
        } else {
-               exec_path = file_info.szPathName;
+               exec_path = exec_fname;
        }
 
        /*

2007-09-21  Eli Zaretskii  <address@hidden>

        * w32/pathstuff.c (convert_Path_to_windows32): Handle quoted
        directories in Path.


--- w32/pathstuff.c~0   2006-02-12 02:16:05.000000000 +0200
+++ w32/pathstuff.c     2007-09-21 11:26:23.375000000 +0200
@@ -70,11 +70,17 @@ convert_Path_to_windows32(char *Path, ch
             } else
                 /* all finished, force abort */
                 p += strlen(p);
+        } else if (*p == '"') { /* a quoted directory */
+            for (p++; *p && *p != '"'; p++) /* skip quoted part */
+                ;
+            etok = strpbrk(p, ":;");        /* find next delimiter */
+           *etok = to_delim;
+            p = ++etok;
         } else {
             /* found another one, no drive letter */
             *etok = to_delim;
             p = ++etok;
-       }
+        }
 
     return Path;
 }


--- w32/pathstuff.c~    2007-09-21 12:26:23.375000000 +0300
+++ w32/pathstuff.c     2009-03-14 18:22:03.765625000 +0200
@@ -49,6 +49,9 @@
     char *p;            /* points to element of old Path */
 
     /* is this a multi-element Path ? */
+    /* FIXME: Perhaps use ":;\"" in strpbrk to convert all quotes to
+       delimiters as well, as a way to handle quoted directories in
+       PATH?  */
     for (p = Path, etok = strpbrk(p, ":;");
          etok;
          etok = strpbrk(p, ":;"))
@@ -71,11 +74,14 @@
                 /* all finished, force abort */
                 p += strlen(p);
         } else if (*p == '"') { /* a quoted directory */
-            for (p++; *p && *p != '"'; p++) /* skip quoted part */
-                ;
-            etok = strpbrk(p, ":;");        /* find next delimiter */
-           *etok = to_delim;
-            p = ++etok;
+                for (p++; *p && *p != '"'; p++) /* skip quoted part */
+                    ;
+                etok = strpbrk(p, ":;");        /* find next delimiter */
+                if (etok) {
+                    *etok = to_delim;
+                    p = ++etok;
+                } else
+                    p += strlen(p);
         } else {
             /* found another one, no drive letter */
             *etok = to_delim;







reply via email to

[Prev in Thread] Current Thread [Next in Thread]