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
Open

Comments

@patricklunney
Copy link

@patricklunney patricklunney commented Mar 14, 2018

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

@josharian josharian commented Mar 14, 2018

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.

@patricklunney
Copy link
Author

@patricklunney 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 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

@patricklunney patricklunney commented Mar 14, 2018

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

@josharian josharian commented Mar 14, 2018

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

@patricklunney patricklunney commented Mar 14, 2018

Sure. What do I do?

@josharian
Copy link
Contributor

@josharian josharian commented Mar 15, 2018

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
@ALTree ALTree added the OS-Darwin label Mar 19, 2018
@odeke-em
Copy link
Member

@odeke-em 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.

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 10, 2018

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.)

@gopherbot gopherbot closed this Aug 10, 2018
@odeke-em odeke-em reopened this Aug 10, 2018
@gopherbot gopherbot closed this Aug 10, 2018
@odeke-em
Copy link
Member

@odeke-em odeke-em commented Aug 10, 2018

@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

@andybons andybons commented Aug 10, 2018

@gopherbot remove label WaitingForInfo

@andybons andybons reopened this Aug 10, 2018
@andybons
Copy link
Member

@andybons andybons commented Aug 10, 2018

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.