Skip to content

Fix SIGBUS race in CPUInstall by extracting to temp dir first#17

Merged
janpfeifer merged 1 commit into
gomlx:mainfrom
ajroetker:fix-cpu-install-race
Feb 18, 2026
Merged

Fix SIGBUS race in CPUInstall by extracting to temp dir first#17
janpfeifer merged 1 commit into
gomlx:mainfrom
ajroetker:fix-cpu-install-race

Conversation

@ajroetker

@ajroetker ajroetker commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

CPUInstall previously extracted the PJRT plugin .so directly to its final install path via Untar. When go test runs multiple packages in parallel, concurrent CPUAutoInstall calls could race: one goroutine writes the .so via Untar while another sees the partially-written file via os.Stat, skips installation, and dlopen-s it, causing SIGBUS.

Fix: extract to a temporary directory (.extracting-*) inside the install path, then os.Rename each file to its final location. Since the temp dir is on the same filesystem, os.Rename is atomic, the .so transitions from nonexistent to complete in a single syscall.

This matches the pattern already used by DownloadURLToTemp for downloads (.tmp + rename), now applied to the extraction step.

CPUInstall previously extracted the PJRT plugin .so directly to its
final install path via Untar. When go test runs multiple packages in
parallel, concurrent CPUAutoInstall calls could race: one goroutine
writes the .so via Untar while another sees the partially-written file
via os.Stat, skips installation, and dlopen-s it — causing SIGBUS.

Fix: extract to a temporary directory (.extracting-*) inside the install
path, then os.Rename each file to its final location. Since the temp dir
is on the same filesystem, os.Rename is atomic — the .so transitions
from nonexistent to complete in a single syscall.

This matches the pattern already used by DownloadURLToTemp for downloads
(.tmp + rename), now applied to the extraction step.
@janpfeifer
janpfeifer merged commit 0b143e1 into gomlx:main Feb 18, 2026
5 checks passed
@ajroetker
ajroetker deleted the fix-cpu-install-race branch February 19, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants