Skip to content

fix: bump gopsutil v3 → v4 to drop go-m1cpu cgo init crash on macOS 26#56

Open
mmoscosa wants to merge 1 commit into
rtalexk:mainfrom
mmoscosa:fix/gopsutil-v4-macos26-cgo
Open

fix: bump gopsutil v3 → v4 to drop go-m1cpu cgo init crash on macOS 26#56
mmoscosa wants to merge 1 commit into
rtalexk:mainfrom
mmoscosa:fix/gopsutil-v4-macos26-cgo

Conversation

@mmoscosa

Copy link
Copy Markdown

Problem

On macOS 26 (Tahoe), Apple Silicon, every demux invocation crashes with SIGSEGV before main() — including demux --version and demux --help:

SIGSEGV: segmentation violation
signal arrived during cgo execution
github.com/shoenig/go-m1cpu._Cfunc_initialize()
github.com/shoenig/go-m1cpu.init.0()  go-m1cpu@v0.1.6/cpu.go:148
runtime.doInit1(...)
runtime.main()

go.mod pins gopsutil/v3, which pulls go-m1cpu (indirect). go-m1cpu reads P/E-core frequencies from IOKit in a cgo init(), and that init segfaults on macOS 26. Because it runs at package-init time, it kills the process before any code executes — no CLI flag avoids it, and CGO_ENABLED=0 is the only workaround (at the cost of losing gopsutil's libproc-backed process detection, so panes read as idle / procs: 0).

Tracked in #55.

Fix

Bump gopsutil/v3gopsutil/v4. v4 dropped the go-m1cpu cgo dependency in favor of sysctl, removing the crash entirely. demux imports gopsutil in only two files (internal/proc/{cwd,snapshot}.go), using only gopsutil/v3/process, and the v4 process API is source-compatible — so this is import-path + module bumps only (4 files, +15/-18).

Verification (macOS 26.5.1 / go 1.26.4 / Apple Silicon)

  • Builds with CGO_ENABLED=1 (the config that crashed) and --version runs cleanly — no segfault.
  • go-m1cpu is fully removed from the dependency graph (go.sum).
  • go vet ./... clean; full go test ./... green.

With cgo back on, per-pane process detection works again — no more blanket idle / procs: 0.

Fixes #55.

gopsutil/v3 pulls github.com/shoenig/go-m1cpu (indirect), which reads
P/E-core frequencies from IOKit in a cgo init(). On macOS 26 (Tahoe,
Apple Silicon) that cgo init segfaults, so every demux invocation —
including `demux --version` and `--help` — dies with SIGSEGV before
main(). No CLI flag can avoid a package-init crash.

gopsutil/v4 replaced the go-m1cpu cgo path with sysctl, so the
dependency is gone entirely. demux only imports gopsutil/v3/process in
two files (internal/proc/{cwd,snapshot}.go); the v4 process API is
source-compatible, so the change is import-path + module bumps only.

Verified on macOS 26.5.1 / go 1.26.4 / Apple Silicon:
- builds with CGO_ENABLED=1 (the config that crashed) and runs cleanly
- go-m1cpu fully removed from the dependency graph
- `go vet ./...` clean, full `go test ./...` green

Fixes rtalexk#55.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

SIGSEGV on startup on macOS 26 (Apple Silicon) — go-m1cpu cgo init

1 participant