Package: make
Version: 4.3-4.1
Severity: normal
Tags: upstream
X-Debbugs-Cc: j...@joshtriplett.org

When make invokes a command without `+` set, it closes the jobserver fds
in that child, but it leaves the --jobserver-auth option set in
MAKEFLAGS pointing to non-existent fds:

/tmp$ cat Makefile
all:
        env | grep jobserver || true ; ls /proc/self/fd
        +env | grep jobserver || true ; ls /proc/self/fd
/tmp$ make -j12
env | grep jobserver || true ; ls /proc/self/fd
MAKEFLAGS= -j12 --jobserver-auth=3,4
MFLAGS=-j12 --jobserver-auth=3,4
0  1  2  3
env | grep jobserver || true ; ls /proc/self/fd
MAKEFLAGS= -j12 --jobserver-auth=3,4
MFLAGS=-j12 --jobserver-auth=3,4
0  1  2  3  4  5

When the invoked command opens a file descriptor, that file descriptor
may then overlap with the referenced jobserver fds. If the invoked
command then subsequently attempted to access the jobserver, it'd
operate on the wrong fd, potentially causing random havoc with the fd
open in that spot.

Removing this flag would also remove the ability of make to notice and
emit a warning ("warning: jobserver unavailable: using -j1. Add '+' to
parent make rule."). However, in the absence of this issue, that warning
would purely be a missed optimization, not a semantic issue. And
optionally, to retain the ability to warn about the missed optimization,
make could change MAKEFLAGS in non-+ rules to pass --jobserver-warn
(without fd numbers), telling make (or any jobserver-capable program) to
emit such a warning about using + without leaving open the possibility
of trying to use the wrong fd as a jobserver.

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: arm64

Kernel: Linux 6.3.0-2-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages make depends on:
ii  libc6  2.37-7

make recommends no packages.

Versions of packages make suggests:
pn  make-doc  <none>

-- no debconf information

Reply via email to