Repository navigation
fix🐛: stop Apple Silicon startup crash from go-m1cpu - #969
Open
fengyikang88 wants to merge 1 commit into
Open
fengyikang88 wants to merge 1 commit into
fengyikang88 wants to merge 1 commit into
Conversation
gopsutil v3 pulls go-m1cpu v0.1.6, whose cgo init dereferences a missing IOKit property on newer Apple Silicon and aborts the process before main. Co-authored-by: Cursor <cursoragent@cursor.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 This is a ...
🔗 Related issue link
No existing issue. Reproduced locally on Apple Silicon while starting the backend from GoLand.
💡 Background and solution
On newer Apple Silicon machines the process dies during package initialization, before
mainruns:go-m1cpuv0.1.6 reads thevoltage-states*-sramIOKit property insideinit()and dereferences it when the property is missing. That property is absent on newer chips (reproduced here on an M6 running macOS / Darwin 27), so every binary that imports the package crashes at startup. Thevariable length array folded to constant arraylines printed just before the crash are only cgo warnings.Two dependencies pull that package in:
github.com/shirou/gopsutil/v3directly.github.com/alibaba/sentinel-golangstill importsgopsutil/v3for system metrics, and v3 is frozen ongo-m1cpuv0.1.6. Switching only our own imports is not enough.Changes:
app/other/apis/sys_server_monitor.gotogithub.com/shirou/gopsutil/v4(v4.26.9). The cpu, mem, disk, host, and net calls used here keep the same signatures, and v4 no longer depends ongo-m1cpu.github.com/shoenig/go-m1cpuv0.2.4 for the copy thatsentinel-golangstill imports throughgopsutil/v3. v0.2.4 checks for a missing IOKit property and initializes lazily instead of crashing ininit().Verified on this machine with
CGO_ENABLED=1:go buildsucceeds.go-admin versionprints2.4.0instead of aborting ingo-m1cpu.init.cpu.Info()together with the Sentinel system metric import returns without a segmentation fault.📝 Changelog
go-m1cpuv0.1.6 dereferencing a missing IOKit property during cgo init.go-m1cpuv0.1.6 在 cgo 初始化时解引用缺失的 IOKit 属性,导致进程在进入main之前段错误退出的问题。☑️ Self-Check before Merge
Made with Cursor