Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: crash at startup on darwin_386 with -linkmode=external #25083

Closed
heschi opened this issue Apr 25, 2018 · 6 comments
Closed

runtime: crash at startup on darwin_386 with -linkmode=external #25083

heschi opened this issue Apr 25, 2018 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Milestone

Comments

@heschi
Copy link
Contributor

heschi commented Apr 25, 2018

On OS X:

$ sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.13.3
BuildVersion:   17D47

A hello world program, built for 386 with CGO_ENABLED=0 and -linkmode=external, crashes at startup with an error in bsdthread_register:

GOARCH=386 CGO_ENABLED=0 go build -ldflags=-linkmode=external src/hello.go && ./hello
# command-line-arguments
loadinternal: cannot find runtime/cgo
fatal error: runtime: bsdthread_register error

runtime stack:
runtime.throw(0x40aa344, 0x21)
        /usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:619 +0x6b fp=0xbffffb64 sp=0xbffffb58 pc=0x4024ddb
runtime.goenvs()
        /usr/local/Cellar/go/1.10/libexec/src/runtime/os_darwin.go:129 +0x63 fp=0xbffffb78 sp=0xbffffb64 pc=0x4022e43
runtime.schedinit()
        /usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:496 +0x88 fp=0xbffffba0 sp=0xbffffb78 pc=0x4027258
runtime.rt0_go(0xbffffc48, 0xc, 0x4197306, 0x0, 0x41b898a, 0x51f800bd, 0x4000000, 0xbffffca0, 0xbffffc50, 0xbffffc18, ...)
        /usr/local/Cellar/go/1.10/libexec/src/runtime/asm_386.s:297 +0x224 fp=0xbffffba4 sp=0xbffffba0 pc=0x4046af4

but works fine with CGO_ENABLED=1:

$ GOARCH=386 CGO_ENABLED=1 go build -ldflags=-linkmode=external src/hello.go && ./hello
hi

Note the loadinternal log, which comes from the linker but does not cause a build failure. I don't know if that's related.

This reproduces with every version of Go I've tried. @randall77 says it works fine on OSX 10.11.

cc @aclements since this is pretty old code with no better owner.

@FiloSottile FiloSottile added OS-Darwin NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 25, 2018
@FiloSottile FiloSottile added this to the Go1.11 milestone Apr 25, 2018
@heschi
Copy link
Contributor Author

heschi commented Apr 25, 2018

Possibly related to #18171, but @andybons reproduced it on a Mac with no antivirus software installed.

@ianlancetaylor
Copy link
Member

This is almost certainly fixed by the work done for #17490. Optimistically closing.

@heschi
Copy link
Contributor Author

heschi commented Jul 9, 2018

Agreed, I think I just forgot to update this. I just rechecked and it's passing now.

@mrajashree
Copy link

@ianlancetaylor There are many PRs referencing this issue #18171, I'm not able to find which one will resolve the error loadinternal: cannot find runtime/cgo. I went through the PRs but the PR descriptions didn't indicate the fix for this. Can you please point me to that PR?

@ianlancetaylor
Copy link
Member

@mrajashree The work for #17490 was a complete overhaul of how the Go runtime interacts with the Mac OS kernel. There was no single CL that fixed any specific problem. If you are encountering the bsdthread_register error, then I think you will need to upgrade to 1.11 when it is available. If you are not seeing a bsdthread_register error, then you likely have a different problem and should open a new issue with details.

@mrajashree
Copy link

@ianlancetaylor okay, thanks for the prompt reply

@golang golang locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Projects
None yet
Development

No branches or pull requests

5 participants