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: panic: runtime error: index out of range on all commands on Darwin #24394

Open
patricklunney opened this issue Mar 14, 2018 · 12 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Milestone

Comments

@patricklunney
Copy link

Please answer these questions before submitting your issue. Thanks!

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

$ go version
panic: runtime error: index out of range

goroutine 1 [running]:
os.executable(...)
/usr/local/Cellar/go/1.10/libexec/src/os/executable_darwin.go:13
os.Executable(...)
/usr/local/Cellar/go/1.10/libexec/src/os/executable.go:21
cmd/go/internal/cfg.findGOROOT(0xc42001e2c0, 0x17)
/usr/local/Cellar/go/1.10/libexec/src/cmd/go/internal/cfg/cfg.go:107 +0x441

Does this issue reproduce with the latest release?

I don't know what version, I think 1.10 based on the .pkg download

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

OSX 10.12

$ go env
panic: runtime error: index out of range

goroutine 1 [running]:
os.executable(...)
/usr/local/Cellar/go/1.10/libexec/src/os/executable_darwin.go:13
os.Executable(...)
/usr/local/Cellar/go/1.10/libexec/src/os/executable.go:21
cmd/go/internal/cfg.findGOROOT(0xc42001e2c0, 0x17)
/usr/local/Cellar/go/1.10/libexec/src/cmd/go/internal/cfg/cfg.go:107 +0x441

What did you do?

Installed go.

Let me know if you need any other docs.
Any idea why it isn't working?

@josharian
Copy link
Contributor

For some reason, runtime/os_darwin.go:sysargs failed to set os.executablePath, or set it to the empty string. There's an obvious recovery fix we should add--sanity check that os.executablePath is non-empty at the beginning of os.executable--but it would be good to know why it is empty in the first place.

Can you try modifying /usr/local/Cellar/go/1.10/libexec/src/runtime/os_darwin.go, func sysargs (at the bottom), to look like this:

func sysargs(argc int32, argv **byte) {
        println("argc", argc)
	// skip over argv, envv and the first string will be the path
	n := argc + 1
	for argv_index(argv, n) != nil {
		n++
	}
        println("n", n)
	executablePath = gostringnocopy(argv_index(argv, n+1))
        println("raw", executablePath)

	// strip "executable_path=" prefix if available, it's added after OS X 10.11.
	const prefix = "executable_path="
	if len(executablePath) > len(prefix) && executablePath[:len(prefix)] == prefix {
		executablePath = executablePath[len(prefix):]
	}
        println("final", executablePath)
}

Then run /usr/local/Cellar/go/1.10/libexec/src/make.bash, and then try go env again and let us know what it says. Thanks.

@josharian josharian added this to the Go1.11 milestone Mar 14, 2018
@josharian josharian added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 14, 2018
@patricklunney
Copy link
Author

patricklunney commented Mar 14, 2018

Made the change and now I get this:

$ sudo /usr/local/Cellar/go/1.10/libexec/src/make.bash
Password:
make.bash must be run from $GOROOT/src

(tried as both sudo and not sudo)

I don't have anything set to $GOROOT
$ echo $GOROOT

What should I set it as?

@uoryon
Copy link

uoryon commented Mar 14, 2018

@patricklunney You can try this.

cd /usr/local/Cellar/go/1.10/libexec/src && ./make.bash

@patricklunney
Copy link
Author

Still didn't work:

$ cd /usr/local/Cellar/go/1.10/libexec/src && ./make.bash
panic: runtime error: index out of range

goroutine 1 [running]:
os.executable(...)
	/usr/local/Cellar/go/1.10/libexec/src/os/executable_darwin.go:13
os.Executable(...)
	/usr/local/Cellar/go/1.10/libexec/src/os/executable.go:21
cmd/go/internal/cfg.findGOROOT(0xc420024280, 0x17)
	/usr/local/Cellar/go/1.10/libexec/src/cmd/go/internal/cfg/cfg.go:107 +0x441

@josharian
Copy link
Contributor

Drat. Bootstrapping. Sadly, it's going to be a bit more complicated than I thought to get a local build going for you to investigate. Are you game for it? Happy to help you through through the process.

@patricklunney
Copy link
Author

Sure. What do I do?

@josharian
Copy link
Contributor

Step one is getting you a functioning Go installation. :) Maybe grab 1.9.4 from https://golang.org/dl/ and put it in some other (non-homebrew) location and see whether it works for you. If not 1.9.4, try 1.8.x. Once that is up and running, export GOROOT_BOOTSTRAP=path/to/working/go. Try executing $GOROOT_BOOTSTRAP/bin/go version to make the envvar is set up correctly. (See https://golang.org/doc/install/source#go14 for lots more detail here.) Then try make.bash again, with that envvar.

@ALTree ALTree changed the title panic: runtime error: index out of range on all commands. runtime: panic: runtime error: index out of range on all commands on Darwin Mar 19, 2018
@odeke-em
Copy link
Member

odeke-em commented May 3, 2018

How's it going @patricklunney? Josh posted some tips in order to bootstrap your Go installation, please take a look. Thank you.

@ianlancetaylor ianlancetaylor added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 10, 2018
@ianlancetaylor ianlancetaylor modified the milestones: Go1.11, Go1.12 Jul 10, 2018
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@odeke-em
Copy link
Member

@andybons @bradfitz could you please help me tame the machine? It just re-closed an issue that I just re-opened

@andybons
Copy link
Member

@gopherbot remove label WaitingForInfo

@andybons andybons removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Aug 10, 2018
@andybons andybons reopened this Aug 10, 2018
@andybons
Copy link
Member

You have to remove the WaitingForInfo label if you re-open a change that is closed do to it being too long since someone responded.

@andybons andybons modified the milestones: Go1.12, Go1.13 Feb 12, 2019
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc removed this from the Go1.14 milestone Oct 9, 2019
@rsc rsc added this to the Backlog milestone Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

9 participants