gwyn%brl-vld@sri-unix.UUCP (03/14/84)
From: Doug Gwyn (VLD/VMB) <gwyn@brl-vld> In UNIX System V (Release 1.0) "make" there is a horrible bug that is masked by a freak accident. The bug surfaced as a side-effect of de-linting the source code. Ron Natalie was the first victim of the newly-awakened bug. Source file dosys.c, in routine doexec(), allocates auto variables: CHARSTAR argv[200]; int status; where `status' is not actually used and `argv' is used to assemble arguments to be passed in a call to execvp(). In source file misc.c, "make" provides its own version of execvp() in order to handle execv() errors; in particular, when an ENOEXEC occurs make's execvp() does something like *--argv = "sh"; execv(shell, argv); to run the (assumed) shell script. HOWEVER, note that decrementing argv is really stupid. On the PDP-11 and the VAX the result is to stuff a pointer to "sh" into `status' in doexec()! If it weren't for the coincidence that `status' wasn't being used for anything worthwhile anyway, this bug would have turned up long ago. I have a quick patch for this bug and several others. Would the USG "make" maintainers please get in touch with me. Yuck!