OSX fatal error: runtime: bsdthread_register error on execution.

10,600 views
Skip to first unread message

Chris Celebi

unread,
Sep 24, 2014, 12:22:00 PM9/24/14
to golan...@googlegroups.com
Hey All,

I could use a little help with my go lang environment. Recently everything was fine. I've definitely done some updates and such. Now I'm getting the following trace no matter what. If I build or even run prebuilt binaries I get the same issue. Has anyone else run into this? 

fatal error: runtime: bsdthread_register error

runtime stack:
runtime.throw(0x141f95)
/usr/local/go/src/pkg/runtime/panic.c:520 +0x69
runtime.goenvs()
/usr/local/go/src/pkg/runtime/os_darwin.c:88 +0x62
runtime.schedinit()
/usr/local/go/src/pkg/runtime/proc.c:164 +0x76
_rt0_go()
/usr/local/go/src/pkg/runtime/asm_amd64.s:91 +0x114
exit status 2


$ go version
go version go1.3.1 darwin/amd64
$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

$ xcodebuild -version
Xcode 6.0.1
Build version 6A317

Chris Celebi

unread,
Sep 25, 2014, 12:46:15 PM9/25/14
to golan...@googlegroups.com
Also this is unrelated to: runtime??throw("runtime: bsdthread_register error (unset DYLD_INSERT_LIBRARIES)");

Dave Cheney

unread,
Sep 25, 2014, 7:28:38 PM9/25/14
to golan...@googlegroups.com
Chris, do you use any AV or "security" (scare quotes intentional) software on this machine ?

The darwin builders on the dashboard run this version of OSX and have not reported any error of this kind.

Chris Celebi

unread,
Sep 26, 2014, 10:46:42 AM9/26/14
to golan...@googlegroups.com
David, I believe we (as in my corporate laptop) definitely has some security and AV software. I wouldn't be surprised if the policy was updated in the last week, which may have broke it. It was fine up until about a week ago. I had installed 1.3.1 installed and was trying out some stuff. I came back to it this week and this started to happen. I couldn't recall anything that has changed from my doing, but it's hard to say what else was done by policy pushes.

bernie...@gmail.com

unread,
Oct 6, 2014, 3:15:02 PM10/6/14
to golan...@googlegroups.com
Opened an issue on this, but no love so far...


Just tried, 1.3.3, no luck...

Dave Cheney

unread,
Oct 7, 2014, 8:35:28 AM10/7/14
to bernie...@gmail.com, golan...@googlegroups.com
Previous reporters of this issue have found their av software was the cause. Are you running any av software on your Mac, if so which?


--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/HtcZc3wO-rw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bernie Durfee

unread,
Oct 7, 2014, 12:57:43 PM10/7/14
to Dave Cheney, golan...@googlegroups.com
McAfee Endpoint Protection and Digital Guardian are the two that I know of. I'm going to try to see if I can get either one or both temporarily disabled/uninstalled to see if either are the culprit.

Chris Celebi

unread,
Oct 7, 2014, 1:20:34 PM10/7/14
to Bernie Durfee, Dave Cheney, golan...@googlegroups.com
No way I'll be able uninstall mine without any serious issues. I have both Symantec and some Websense software.

Dmitri Shuralyov

unread,
Oct 7, 2014, 6:18:12 PM10/7/14
to golan...@googlegroups.com, bernie...@gmail.com, da...@cheney.net
You say it's unrelated to "runtime??throw("runtime: bsdthread_register error (unset DYLD_INSERT_LIBRARIES)");", how do you know that?

I had to do _set_ that env var recently because I had a similar issue begin to occur. This change fixed it:


Can you try setting DYLD_INSERT_LIBRARIES to a blank value and see what happens?

Bernie Durfee

unread,
Oct 8, 2014, 11:59:11 AM10/8/14
to Dmitri Shuralyov, golan...@googlegroups.com
Found something interesting, now suspecting DigitalGuardian is the issue.

# I checked for DYLD_INSERT_LIBRARIES in the environment
> env | grep DYLD_INSERT_LIBRARIES


# Nothing there... maybe...
# I then tried the suggestion of setting the variable as empty...
> export DYLD_INSERT_LIBRARIES=


# Let's double-check to make sure it's empty...
> env | grep DYLD_INSERT_LIBRARIES
DYLD_INSERT_LIBRARIES=/usr/lib/dgagent/libpreload.dylib
DYLD_INSERT_LIBRARIES=


Now appears the apparently hidden environment variable set by Digital Guardian. Not quite sure how that's possible. :)

Not sure where or how Digital Guardian is injecting that environment variable, but I'm guessing that's the issue.

I'm going to do an experiment later this week on a laptop with Digital Guardian temporarily disabled to see if it fixes the issue. Though, I am assuming that it'll confirm that DG is the issue.


Uninstalling Digital Guardian is, unfortunately, a not an option. Is this fixable?

Tamás Gulácsi

unread,
Oct 8, 2014, 1:26:42 PM10/8/14
to golan...@googlegroups.com
You would need a DG-free environment, which is hard if you cannot become root.

Chris Celebi

unread,
Oct 8, 2014, 2:29:27 PM10/8/14
to golan...@googlegroups.com
Seems I'm in that boat. Setting and unsetting doesn't resolve the issue. Definitely a security software blocking issue.

fatal error: runtime: bsdthread_register error (unset DYLD_INSERT_LIBRARIES)

runtime stack:
runtime.throw(0x141f55)
/usr/local/go/src/pkg/runtime/panic.c:520 +0x69
runtime.goenvs()
/usr/local/go/src/pkg/runtime/os_darwin.c:87 +0x54
runtime.schedinit()
/usr/local/go/src/pkg/runtime/proc.c:164 +0x76
_rt0_go()
/usr/local/go/src/pkg/runtime/asm_amd64.s:91 +0x114

unset DYLD_INSERT_LIBRARIES
./hello
fatal error: runtime: bsdthread_register error

runtime stack:
runtime.throw(0x141f95)
/usr/local/go/src/pkg/runtime/panic.c:520 +0x69
runtime.goenvs()
/usr/local/go/src/pkg/runtime/os_darwin.c:88 +0x62
runtime.schedinit()
/usr/local/go/src/pkg/runtime/proc.c:164 +0x76
_rt0_go()
/usr/local/go/src/pkg/runtime/asm_amd64.s:91 +0x114

Dmitri Shuralyov

unread,
Oct 8, 2014, 9:36:51 PM10/8/14
to golan...@googlegroups.com, shur...@gmail.com, bernie...@gmail.com
That's not the case for me. Setting it to a blank value behaves as expected. (I don't know what Digital Guardian is and I probably don't have it.)

~ $ env | grep DYLD_INSERT_LIBRARIES
~ $ export DYLD_INSERT_LIBRARIES=
~ $ env | grep DYLD_INSERT_LIBRARIES
DYLD_INSERT_LIBRARIES=
~ $ 

bernie...@gmail.com

unread,
Oct 9, 2014, 2:00:04 PM10/9/14
to golan...@googlegroups.com
Will Go not work if DYLD_INSERT_LIBRARIES is set by another process?

Bernie


On Wednesday, September 24, 2014 12:22:00 PM UTC-4, Chris Celebi wrote:

mail...@gmail.com

unread,
Jan 8, 2015, 6:53:39 PM1/8/15
to golan...@googlegroups.com, bernie...@gmail.com
I ran into this exact same issue today when I was trying to install "gocart". Based on responses in this thread, I tried to set the following:
export DYLD_INSERT_LIBRARIES=
Then, I did the following:

$ env | grep DYLD_INSERT_LIBRARIES

DYLD_INSERT_LIBRARIES=/usr/lib/dgagent/libpreload.dylib

DYLD_INSERT_LIBRARIES=


As you can see the Digital Guardian libraries are automatically set. Then when I tried to install gocart again, this time it worked like a charm. So for me, all I had to do was to set DYLD_INSERT_LIBRARIES to a blank value. 

Young Lee

unread,
Jun 27, 2015, 12:37:39 PM6/27/15
to golan...@googlegroups.com
I am in the same boat as you.  Were you able to resolve this error and use go on Mac OS X? I am running 10.9.5.

I am hoping someone on this list can help, since the discovery of the problem was almost a year ago.

FWIW, I am running go 1.4.2 on a corporate laptop.  And yes we have McAfee DLP and websense both installed and removing them is not an option.

unsetting the DYLD_INSERT_LIBRARIES does not work for me either.

:(, please help...

Chris Celebi

unread,
Jul 1, 2015, 5:06:11 PM7/1/15
to Young Lee, golan...@googlegroups.com
It happened to be some kind of security software that was doing this. Strangely after updating OSX, it resolved this problem, which was later re-introduced to me.

--

Ian Lance Taylor

unread,
Jul 18, 2015, 1:49:49 AM7/18/15
to Young Lee, golang-nuts
On Fri, Jul 17, 2015 at 10:04 PM, Young Lee <you...@gmail.com> wrote:

The stack trace shows that it is faling in the runtime.goenvs() function which is line 104 in the os_darwin.c.  Highlighted line is where it is failing.  Since this is my first time ever looking inside the golang source code, can someone with internals knowledge explain reasons why runtime·bsdthread_register() is returning a nonzero value?  Understanding that is a key for me to resolve this issue.

 I assume you've seen http://golang.org/issue/8801 and the discussions it links to.  Chris already pointed out that it could be security software, such as some kinds of virus checkers; are you running anything like that?

bsdthread_register is a Darwin system call that sets up the threading system.  My understanding is that it returns non-zero if it has already been called by the process.

Ian

Young Lee

unread,
Jul 18, 2015, 4:46:28 AM7/18/15
to Ian Lance Taylor, golang-nuts
Thanx Ian,

I am having this problem on my company issued Mac OS X and it is running "McAfee Endpoint Protection for Mac" software Version 2.1.0 (1085).  Also "Websense Endpoint" software Version 7.8.1826 is running as well.  Both of these software are installed as a company policy so it is not an option to disable it.

Another interesting bit is that I just found out that one of my colleague who also has a company issued Mac and he had told me that he can run go programs just fine.  I am planning to get together with him next week to compare the env and troubleshoot...

Stay tuned... and will report back on what I find out...
--
Thanx,

- Young
(Sent from mobile, please excuse typos)

demetri...@gmail.com

unread,
Jul 21, 2015, 9:55:48 PM7/21/15
to golang-nuts
Try writing a C program that reports duplicate environment variable name or names that are invalid (contain NUL)in extern char **environ.

Young Lee

unread,
Jul 24, 2015, 6:55:57 AM7/24/15
to golang-nuts, ia...@golang.org, you...@gmail.com
Hi,

After couple of debugging sessions with my colleague, we were able to determine that in my enviroment, the culprit was the "Websense Endpoint" software.  With some help from the company, I was able to turn off WebSense.  The simple helloworld go program worked as expected with Websense disabled.

Thanx for all the help.

neha...@gmail.com

unread,
Sep 3, 2015, 7:17:37 PM9/3/15
to golang-nuts
If you build with -ldflags -linkmode=external then you should not get this error anymore. 

Thanks
Neha
Message has been deleted
Message has been deleted

shub...@gmail.com

unread,
Oct 9, 2015, 2:50:56 PM10/9/15
to golang-nuts, neha...@gmail.com
Worked like a charm. Thanks Neha!!!

vch...@gmail.com

unread,
Jan 5, 2016, 1:57:42 PM1/5/16
to golang-nuts, neha...@gmail.com, shub...@gmail.com
Hi ,
I am trying to build and run a simple Go prrogram on my mac. I tried with and without the -ldflags. Same issue

go build -ldflags -linkmode=external main.go


# command-line-arguments

fatal error: runtime: bsdthread_register error


runtime stack:

runtime.throw(0x4576a0, 0x21)

/usr/local/go/src/runtime/panic.go:527 +0x90 fp=0x7fff5fbff680 sp=0x7fff5fbff668

runtime.goenvs()

/usr/local/go/src/runtime/os1_darwin.go:73 +0x8d fp=0x7fff5fbff6a8 sp=0x7fff5fbff680

runtime.schedinit()

/usr/local/go/src/runtime/proc1.go:60 +0x83 fp=0x7fff5fbff6f0 sp=0x7fff5fbff6a8

runtime.rt0_go(0x7fff5fbff728, 0x10, 0x7fff5fbff728, 0x0, 0x0, 0x10, 0x7fff5fbff910, 0x7fff5fbff93c, 0x7fff5fbff93f, 0x7fff5fbff99b, ...)

/usr/local/go/src/runtime/asm_amd64.s:109 +0x132 fp=0x7fff5fbff6f8 sp=0x7fff5fbff6f0



My go env

GOARCH="amd64"

GOBIN=""

GOEXE=""

GOHOSTARCH="amd64"

GOHOSTOS="darwin"

GOOS="darwin"

GOPATH="/workspace-go/dnsproxy"

GORACE=""

GOROOT="/usr/local/go"

GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"

GO15VENDOREXPERIMENT=""

vch...@gmail.com

unread,
Jan 5, 2016, 2:25:57 PM1/5/16
to golang-nuts, neha...@gmail.com, shub...@gmail.com, vch...@gmail.com
Some more findings:
I was having below issues  after installing GoLang  from https://golang.org/doc/install   go1.5.2.darwin-amd64.pkg installer.
Then I went ahead and installed GO using brew on Mac.

New ENV

GOARCH="amd64"

GOBIN=""

GOEXE=""

GOHOSTARCH="amd64"

GOHOSTOS="darwin"

GOOS="darwin"

GOPATH="/workspace-go/test"

GORACE=""

GOROOT="/usr/local/Cellar/go/1.5.2/libexec"

GOTOOLDIR="/usr/local/Cellar/go/1.5.2/libexec/pkg/tool/darwin_amd64"

GO15VENDOREXPERIMENT=""

CC="clang"

GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"

CXX="clang++"

CGO_ENABLED="1"


after doing 

export DYLD_LIBRARY_PATH=

and then building 

go build -ldflags -linkmode=external main.go

I was able to run the test program.


The only difference between both GO ENV  is 


GO 

< GOROOT="/usr/local/go"

< GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"

---

BREW GO

> GOROOT="/usr/local/Cellar/go/1.5.2/libexec"

> GOTOOLDIR="/usr/local/Cellar/go/1.5.2/libexec/pkg/tool/darwin_amd64"




On Tuesday, January 5, 2016 at 1:57:42 PM UTC-5, vch...@gmail.com wrote:
Hi ,
I am trying to build and run a simple Go prrogram on my mac. I tried with and without the -ldflags. Same issue

go build -ldflags -linkmode=external main.go


# command-line-arguments

fatal error: runtime: bsdthread_register error


runtime stack:

runtime.throw(0x4576a0, 0x21)

/usr/local/go/src/runtime/panic.go:527 +0x90 fp=0x7fff5fbff680 sp=0x7fff5fbff668

runtime.goenvs()

/usr/local/go/src/runtime/os1_darwin.go:73 +0x8d fp=0x7fff5fbff6a8 sp=0x7fff5fbff680

runtime.schedinit()

/usr/local/go/src/runtime/proc1.go:60 +0x83 fp=0x7fff5fbff6f0 sp=0x7fff5fbff6a8

runtime.rt0_go(0x7fff5fbff728, 0x10, 0x7fff5fbff728, 0x0, 0x0, 0x10, 0x7fff5fbff910, 0x7fff5fbff93c, 0x7fff5fbff93f, 0x7fff5fbff99b, ...)

/usr/local/go/src/runtime/asm_amd64.s:109 +0x132 fp=0x7fff5fbff6f8 sp=0x7fff5fbff6f0



My go env

GOARCH="amd64"

GOBIN=""

GOEXE=""

GOHOSTARCH="amd64"

GOHOSTOS="darwin"

GOOS="darwin"

GOPATH="/workspace-go/test"

Peter Herth

unread,
Jan 7, 2016, 5:50:02 PM1/7/16
to golang-nuts
Hi all,

I have the same problem on Yosemite, go 1.5.2, but was not able to unset DYLD_INSERT_LIBARIES. Is there a way to change the call to bsdthread_register so it can work around those issues?

Best regards,
Peter

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.

ken...@gmail.com

unread,
Jan 22, 2016, 10:31:23 AM1/22/16
to golang-nuts
The same here.


On Wednesday, 24 September 2014 17:22:00 UTC+1, Chris Celebi wrote:
Hey All,

I could use a little help with my go lang environment. Recently everything was fine. I've definitely done some updates and such. Now I'm getting the following trace no matter what. If I build or even run prebuilt binaries I get the same issue. Has anyone else run into this? 

fatal error: runtime: bsdthread_register error

runtime stack:
runtime.throw(0x141f95)
/usr/local/go/src/pkg/runtime/panic.c:520 +0x69
runtime.goenvs()
/usr/local/go/src/pkg/runtime/os_darwin.c:88 +0x62
runtime.schedinit()
/usr/local/go/src/pkg/runtime/proc.c:164 +0x76
_rt0_go()
/usr/local/go/src/pkg/runtime/asm_amd64.s:91 +0x114
exit status 2
$ go version
go version go1.3.1 darwin/amd64
$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

rossrot...@gmail.com

unread,
May 17, 2016, 1:53:29 PM5/17/16
to golang-nuts
I was getting this error, but I fixed it by building go from source and then using that as my GOROOT.
Reply all
Reply to author
Forward
0 new messages