Repository navigation
Description
An interrupt during pip seeding can close temporary app-data while a seed worker still uses it. In a local run, the worker continued after cleanup and a temporary folder remained after virtualenv exited.
Affected code
- Seed worker startup and join
- Session cleanup and temporary app-data removal
- Image extraction starts after the log line
Mechanism
The seeder starts worker threads and joins them on the normal path. If SIGINT interrupts join(), control reaches Session.__exit__, which removes temporary app-data while the worker continues. Thread.join() waits for a thread to terminate; the interrupted path does not complete that wait.
Reproduction
I built a wheel from commit ebe06113f440731ab9c5bd6506a4793140532dc9, installed it in a Python 3.15 environment, and ran this single-user reproducer. It sends SIGINT when pip image extraction starts and removes any folder left by the run after recording the result.
import os
import re
import shutil
import signal
import subprocess
import sys
import tempfile
from pathlib import Path
checkout = Path(sys.argv[1])
with tempfile.TemporaryDirectory(prefix="virtualenv-interrupt-") as work:
env = {**os.environ, "HOME": "/nonexistent"}
process = subprocess.Popen(
[sys.executable, "-m", "virtualenv", "--no-periodic-update", "-vvv", str(Path(work) / "venv")],
cwd=checkout,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
bufsize=1,
)
lines = []
cache = None
interrupted = False
for line in process.stdout:
if (
"temporary app data folder" in line
or "build install image for pip" in line
or "KeyboardInterrupt" in line
or ("Lock " in line and " released on " in line and "wheel" in line)
):
lines.append(line.strip())
if "created temporary app data folder" in line:
cache = Path(re.search(r"(/tmp/tmp\w+)", line).group(1))
if "build install image for pip" in line and not interrupted:
process.send_signal(signal.SIGINT)
interrupted = True
process.wait()
print("commit:", subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], cwd=checkout, text=True).strip())
print("exit:", process.returncode)
print("sent SIGINT:", interrupted)
for line in lines:
print(line)
print("temporary folder exists after exit:", cache.exists() if cache else None)
if cache and cache.exists():
print("temporary folder mode:", oct(cache.stat().st_mode & 0o777))
shutil.rmtree(cache)$ python repro.py /path/to/ebe06113-checkout
commit: ebe06113
exit: 1
sent SIGINT: True
64 created temporary app data folder /tmp/tmpfhh51397 [DEBUG via_tempdir:35]
200 build install image for pip-26.3-py3-none-any.whl to /tmp/tmpfhh51397/wheel/3.15/image/1/CopyPipInstall-pip-26.3-py3-none-any [DEBUG base:268]
200 remove temporary app data folder /tmp/tmpfhh51397 [DEBUG via_tempdir:42]
846 Lock 140577566815440 released on /tmp/tmpfhh51397/wheel/3.15/image/1/CopyPipInstall/pip-26.3-py3-none-any.lock [DEBUG _api:367]
temporary folder exists after exit: True
temporary folder mode: 0o700The cleanup log precedes the worker's lock release, and the temporary folder exists after exit. Expected: the session waits for its seed workers to finish before removing their temporary app-data, leaving no folder from this run.
Impact
An interrupted seed can leave temporary app-data behind. Reproducibility is hard because the interrupt must land during seeding. Exposure is unlikely because the run must use temporary app-data and be interrupted in that interval. This reproduction establishes the cleanup and worker ordering and the leftover folder.
Credits
Reported by @oss-scanner as ANT-2026-02O7K288.
Activity
🐛 fix(seed): wait for workers before cleanup
🐛 fix(seed): wait for workers before cleanup
🐛 fix(seed): wait for workers before cleanup
🐛 fix(seed): wait for workers before cleanup
🐛 fix(seed): wait for workers before cleanup