python / python/cpython

Build failure: install race condition

オープン
#102,007 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

build type-bug
主要言語
Python
スター
77.2k
フォーク
36k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供された Makefile と make -j2 を使って失敗を再現し、その後、commoninstallaltbininstalllibinstall に対して生成されたインストールルールを調べます。共有ディレクトリの作成時に、GNU Make 4.4 と Python 3.11 の組み合わせを含め、並列 make install で競合が発生しなくなれば修正完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
build-system
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。