go: runtime: bsdthread_register fatal error (CylancePROTECT)

What version of Go are you using (go version)?

go version go1.8beta1

What operating system and processor architecture are you using (go env)?

GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/kevin.saldana/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

uname -prsv
Darwin 14.5.0 Darwin Kernel Version 14.5.0: Mon Aug 29 21:14:16 PDT 2016; root:xnu-2782.50.6~1/RELEASE_X86_64 i386

What did you do?

Any call to go build/tools fails with

fatal error: runtime: bsdthread_register error
runtime stack:
runtime.throw(0x16b2b8c, 0x21)
   /usr/local/go/src/runtime/panic.go:596 +0x95 fp=0x7fff5fbff180 sp=0x7fff5fbff160
runtime.goenvs()
   /usr/local/go/src/runtime/os_darwin.go:108 +0xa0 fp=0x7fff5fbff1b0 sp=0x7fff5fbff180
runtime.schedinit()
   /usr/local/go/src/runtime/proc.go:476 +0xa1 fp=0x7fff5fbff1f0 sp=0x7fff5fbff1b0
runtime.rt0_go(0x7fff5fbff220, 0x11, 0x7fff5fbff220, 0x0, 0x11, 0x7fff5fbff490, 0x7fff5fbff4bc, 0x7fff5fbff4bf, 0x7fff5fbff549, 0x7fff5fbff553, ...)

What did you expect to see?

Working builds.

I have gone through all threads related to this error and have tried their solutions (disabling anti-virus, messing with DYLD environment variables, adding -ldflags -linkmode=external to build) and am still running into this issue.

Note, I am running an old version of OSX – Yosemite v10.10.5.

I have tried both building from source and using the installer. Same effect either way.

Downgrading to 1.7.4 does not run into this error.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 51 (22 by maintainers)

Most upvoted comments

Figured out how to temporarily work around this, everytime i start my computer i run:

sudo launchctl unload /Library/launchdaemons/com.cylance.agent_service.plist

@rsc @abscondment @bru7us I am experiencing the same issue but do not have the update mentioned for cylance.

Mac OSX Sierra 10.12.5 Cylance Agent Version 2.0.1440.541 (No other available update to push from the console) Go Version: go1.8.3 darwin/amd64

Do you know when this update will get pushed to Sierra?

We can close this issue forever by making all Go binaries built for OS X implicitly import “runtime/cgo” (when CGO_ENABLED=1). Then Go will always use libpthread for thread creation and not call bsdthread_register (again assuming cgo is enabled).

I don’t want to play the game of trying to make antivirus happy. Nobody ever seems to win that game.

Can confirm that this happens with Go 1.8 on OS X El Cap 10.11.6 running Cylance 1.2.1418.609.

Just thought I’d chime in, just ran into this as well in the upgrade to 1.8. I was running CylanceProtect and it would throw the same errors. Strangely 1.7.x had no issues.

FWIW: El Capitan and go 1.8.3 with CylancePROTECT (now at 2.0.1450.506) not producing the error where this same machine was producing it before a Cylance update.

@DemiMarie, I agree we might want to do that in the long term, but it’s tricky to bootstrap (see https://github.com/golang/go/issues/18171#issuecomment-285098816 and https://github.com/golang/go/issues/18171#issuecomment-293366609 above).

@j-mroz, thanks very much for finding that. Can you send a CL, even if it breaks net/http? Maybe someone else can figure out what’s wrong with net/http. Also network tests on macOS are flaky under some configurations, apparently due to problems with the macOS network stack. So your change might be fine.

Thanks everyone.

It’s not just antivirus, though. It’s also DTrace. See #17819, merged (I think incorrectly) into #17490.