gmake-4.2.90 regression (error message missing)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

gmake-4.2.90 regression (error message missing)

Gnu - Make - Bugs mailing list
Good morning.

Certian implementations of posix_spawn return 0 on failure and then
exit the child process with 127. I observed this with older glibc
(2.12) and on aix.

This results in gmake not printing related error message "no such
file" or "permission denied" when the command is missing or not
executable. This also causes multiple tests to fail.

$ echo 'all: ; @./foo' > /tmp/1.mk
$ ./make-4.2.90  -f /tmp/1.mk
make-4.2.90: *** [/tmp/1.mk;1: all] Error 127
$ ./make.patched  -f /tmp/1.mk
make.patched: ./foo: No such file or directory
make.patched: *** [/tmp/1.mk;1: all] Error 127

This patch executes posix_spawnp at configuration time and then
disables posix_spawn if posix_spawn returns 0 on an attempt to exec a
missing file.
This solution won't work for cross compilation.

regards, Dmitry

index f6919a7..9da113c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,7 +142,7 @@ AC_CHECK_FUNCS([strdup strndup umask mkstemp mktemp fdopen \
                 dup dup2 getcwd realpath sigsetmask sigaction \
                 getgroups seteuid setegid setlinebuf setreuid setregid \
                 getrlimit setrlimit setvbuf pipe strsignal \
-                lstat readlink atexit isatty ttyname pselect posix_spawn \
+                lstat readlink atexit isatty ttyname pselect
posix_spawn posix_spawnp \
                 posix_spawnattr_setsigmask])

 # We need to check declarations, not just existence, because on Tru64 this
@@ -368,7 +368,18 @@ AC_ARG_ENABLE([posix-spawn],
 AS_CASE([/$ac_cv_header_spawn/$ac_cv_func_posix_spawn/],
   [*/no/*], [make_cv_posix_spawn=no])

-AS_CASE([/$make_cv_posix_spawn/$user_posix_spawn/],
+AC_RUN_IFELSE(
+       [AC_LANG_PROGRAM([
+            #include <spawn.h>
+            #include <errno.h>], [
+            char* av[[]] = {"./macarie", '\0'};
+            char* envp[[]] = {'\0'};
+            return posix_spawnp(0, av[[0]], 0, 0, av, envp) != ENOENT; ])],
+      [posix_spawn_is_good="yes"],
+      [posix_spawn_is_good="no"]
+)
+
+AS_CASE([/$make_cv_posix_spawn/$user_posix_spawn/$posix_spawn_is_good/],
   [*/no/*], [make_cv_posix_spawn=no],
   [AC_DEFINE(USE_POSIX_SPAWN, 1, [Define to 1 to use posix_spawn().])
   ])

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

Re: gmake-4.2.90 regression (error message missing)

Paul Smith-20
On Sun, 2019-09-01 at 15:33 -0400, Dmitry Goncharov via Bug reports and
discussion for GNU make wrote:
> This patch executes posix_spawnp at configuration time and then
> disables posix_spawn if posix_spawn returns 0 on an attempt to exec a
> missing file.
> This solution won't work for cross compilation.

Thanks Dmitry.  I guessed at this issue during testing:

https://lists.gnu.org/archive/html/bug-make/2019-08/msg00063.html

I have a different solution in mind that doesn't require using
configure tests and won't have issues with cross-compilation: I'm just
handling the 127 exit code and generating the appropriate error message
directly.


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

Re: gmake-4.2.90 regression (error message missing)

Gnu - Make - Bugs mailing list
You were planning to use stat, right? Are you planning to stat the
interperter specified in shebang as well?
Some of the races can be avoided by opening the file before
posix_spawn and then using fstat on the fd.
Alternatively that posix_spawn check from configure.ac can be executed
at runtime to support cross compilation.

regards, Dmitry


On Mon, Sep 2, 2019 at 9:44 AM Paul Smith <[hidden email]> wrote:

>
> On Sun, 2019-09-01 at 15:33 -0400, Dmitry Goncharov via Bug reports and
> discussion for GNU make wrote:
> > This patch executes posix_spawnp at configuration time and then
> > disables posix_spawn if posix_spawn returns 0 on an attempt to exec a
> > missing file.
> > This solution won't work for cross compilation.
>
> Thanks Dmitry.  I guessed at this issue during testing:
>
> https://lists.gnu.org/archive/html/bug-make/2019-08/msg00063.html
>
> I have a different solution in mind that doesn't require using
> configure tests and won't have issues with cross-compilation: I'm just
> handling the 127 exit code and generating the appropriate error message
> directly.
>

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

Re: gmake-4.2.90 regression (error message missing)

Paul Smith-20
On Tue, 2019-09-03 at 10:54 -0400, Dmitry Goncharov wrote:
> You were planning to use stat, right? Are you planning to stat the
> interperter specified in shebang as well?
> Some of the races can be avoided by opening the file before
> posix_spawn and then using fstat on the fd.
> Alternatively that posix_spawn check from configure.ac can be executed
> at runtime to support cross compilation.

I'm going to use a trivial best-effort approach, that should be
sufficient to allow the regression tests to pass.

I don't plan to care overly much about race conditions, weird
interpreter/shebang issues, etc.  If a simple attempt to detect and
emulate the old-school fork/exec behavior doesn't pan out, I'll just
show the failure as exit 127 like we do now.  I don't think it's
worthwhile to spend more effort on it than that, or to throw out
posix_spawn() completely simply because some error messages are not as
clear as they used to be--especially these type of errors which are due
to fundamental failures in the build environment (trying to invoke non-
executable files or non-existent files), not everyday things like
failing compilations or whatever.


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make