Go Wiki:MacOS12BSDThreadRegisterIssue
簡介
如果您是因為看到類似以下由執行於 macOS 12 Monterey 的 Go 程式印出的錯誤訊息而到達此頁面
fatal error: runtime: bsdthread_register error
runtime stack:
runtime.throw(0x20594e0, 0x21)
/usr/local/go/src/runtime/panic.go:619 +0x81 fp=0x7ff7bfeff878 sp=0x7ff7bfeff858 pc=0x1029751
runtime.goenvs()
/usr/local/go/src/runtime/os_darwin.go:129 +0x83 fp=0x7ff7bfeff8a8 sp=0x7ff7bfeff878 pc=0x10272d3
runtime.schedinit()
/usr/local/go/src/runtime/proc.go:496 +0xa4 fp=0x7ff7bfeff900 sp=0x7ff7bfeff8a8 pc=0x102c014
runtime.rt0_go(0x7ff7bfeff930, 0x3, 0x7ff7bfeff930, 0x1000000, 0x3, 0x7ff7bfeffab0, 0x7ff7bfeffabf, 0x7ff7bfeffac3, 0x0, 0x7ff7bfeffacc, ...)
/usr/local/go/src/runtime/asm_amd64.s:252 +0x1f4 fp=0x7ff7bfeff908 sp=0x7ff7bfeff900 pc=0x1052c64
表示您執行的程式是使用舊版 Go (Go 1.10 或更早版本) 建置的。您需要更新程式或使用較新版本的 Go 重新建置程式。
詳細資料
使用 Go 1.10 或更早版本編譯的程式,使用 macOS 12 Monterey 上的內核不再支援的系統呼叫方式。在 Go 1.11 及更新版本中,系統呼叫是透過作業系統支援的 libSystem.dylib
發出的。
該如何做
如果是下載或安裝的程式(例如,使用 Homebrew),您需要下載或安裝使用更新版本的 Go 編譯的更新版本。
如果是從原始碼編譯的程式,您需要使用更新版本的 Go 重新編譯。
您可能想要檢查您的 $PATH 並手動清理 $GOPATH/bin
和其他已安裝的舊相關 Go 二進制檔案。
如果您嘗試編譯 Go,go tool dist clean
可能會有幫助。
此內容是 Go Wiki 的一部分。