python / python/cpython

Build failure: install race condition

Offen
#102,007 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

build type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
36k
Ø Merge
1 T. 9 Std.
Gemergte PRs (30 T.)
558

Beschreibung

Bug report

The generated Makefile for Python 3.11 has a race condition in its install target.

So far it triggers easiest with GNU Make 4.4 (I think they distribute more tasks breadth first instead of depth first compared to v4.3)

In short, this is a reproducer of the problem:

LIBDIR := $(CURDIR)/lib
INSTALL := /usr/bin/install -c

all: a b

a b:
	@for i in $(LIBDIR); do \
		if test ! -d $$i; then \
			echo "Creating directory $$i"; \
			$(INSTALL) -d -m 755 $$i; \
		else true; \
		fi \
	done

causing a race as follows:

% make -j2
Creating directory /private/var/folders/33/7njsb0_50dl7hnkr58nbnpb00000gn/T/tmp.TOdJ6wpw/lib
Creating directory /private/var/folders/33/7njsb0_50dl7hnkr58nbnpb00000gn/T/tmp.TOdJ6wpw/lib
install: mkdir /private/var/folders/33/7njsb0_50dl7hnkr58nbnpb00000gn/T/tmp.TOdJ6wpw/lib: File exists
make: *** [a] Error 71

This happens exactly in Python during make install -j$(nproc) as the commoninstall target has the prereqs altbininstall libinstall (among others) which both have a shell script loop over some directories they wanna make, and in particular it has:

altbininstall: $(BUILDPYTHON)
	@for i in $(BINDIR) $(LIBDIR); \
		... like example above (if dir not exists, run install)

libinstall: all $(srcdir)/Modules/xxmodule.c
	@for i in $(SCRIPTDIR) $(LIBDEST); \
		... like example above (if dir not exists, run install)

where SCRIPTDIR and LIBDIR in my case both point to <prefix>/lib.

Your environment

Python 3.11
GNU Make 4.4
macOS Ventura M1

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, den Fehler mit der bereitgestellten Makefile und make -j2 zu reproduzieren, und untersuche dann die generierten Installationsregeln für commoninstall, altbininstall und libinstall. Die Fehlerbehebung ist abgeschlossen, wenn paralleles make install beim Erstellen gemeinsamer Verzeichnisse nicht mehr zu Race Conditions führt, einschließlich mit GNU Make 4.4 unter Python 3.11.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
build-system
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.