[Top][All Lists]

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

Re: [PATCH] tests: fix test-execute with GNU make jobserver

From: Bruno Haible
Subject: Re: [PATCH] tests: fix test-execute with GNU make jobserver
Date: Wed, 07 Apr 2021 23:30:47 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-206-generic; KDE/5.18.0; x86_64; ; )

Hi Dmitry,

Thanks for the proposed patch.

> On POSIX systems the GNU make jobserver is implemented as a pipe,
> and these two unexpected descriptors make test-execute-child fail.

This problem description is a bit technical. It took me a bit of work
to translate your description into a "how to reproduce". Namely,

  $ make -j 8 check

produces this output:

  Test case 14: 0 1 2 3 4 10 
  test-execute-main.c:295: assertion 'ret == 0' failed
  Aborted (core dumped)
  test-execute.sh: test case 14 failed
  Test case 15: 0 1 2 3 4 10 
  test-execute-main.c:305: assertion 'ret == 0' failed
  Aborted (core dumped)
  test-execute.sh: test case 15 failed
  Test case 16: 0 1 2 3 4 
  test-execute-main.c:315: assertion 'ret == 0' failed
  Aborted (core dumped)
  test-execute.sh: test case 16 failed

Now, there are several questions:

1) Why is GNU make passing these descriptors 3 and 4 to the child
process? The Makefile rule looks like this:

test-execute.sh.log: test-execute.sh
        @p='test-execute.sh'; \
        b='test-execute.sh'; \
        $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
        --log-file $$b.log --trs-file $$b.trs \
        $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) 
        "$$tst" $(AM_TESTS_FD_REDIRECT)

and it does not start with '+'. (Cf. [1].)

Oh, I see: $(am__check_pre) expands to something that contains
and that occurrence of $(MAKE) makes 'make' think that the rule may
execute a sub-make.

2) You suggest to deal with the file descriptors 3..19. Is this reliable?
The MAKEFLAGS variable in the environment is defined as
  MAKEFLAGS="w -j8 --jobserver-auth=3,4 -- ..."
So we could parse this string and look for the --jobserver-auth

Oh, wait: this option was named differently in older GNU make versions.[2]

3) You suggest to set the cloexec bit on these file descriptors, so that
test-execute-child will have them closed. However, it is simpler to just
close() them in test-execute-parent already, since test-execute-parent
does not need these file descriptors either.

4) How about other environments? I saw 'test-execute.sh' also fail in
some recent Linux distro with KDE desktop. Apparently 'plasma' is passing
one or two open file descriptors to all children (that is, to all processes
running in this desktop environment). Do you think this is worth reporting?

5) Will glibc at some point export the close_range() function [3]?
If so, Gnulib should probably provide a substitute close_range(), and
test-execute-main.c should better call this function, rather than rolling
its own loop.


[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=827132
[3] https://lwn.net/Articles/789000/

reply via email to

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