Build failure: install race condition
還沒有人認領這個 Issue。
- 主要語言
- 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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先使用提供的 Makefile 和 make -j2 重現失敗,然後檢查為 commoninstall、altbininstall 和 libinstall 產生的安裝規則。當平行執行 make install 時建立共用目錄不再發生競爭(包括在 Python 3.11 上使用 GNU Make 4.4 時),修正就完成了。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- build-system
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100