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

cmd/go: panic in base.SetFromGOFLAGS #42013

Open
tie opened this issue Oct 16, 2020 · 6 comments
Open

cmd/go: panic in base.SetFromGOFLAGS #42013

tie opened this issue Oct 16, 2020 · 6 comments

Comments

@tie
Copy link
Contributor

@tie tie commented Oct 16, 2020

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

go version devel +66e66e7113 Sun Sep 13 19:17:09 2020 +0000 darwin/amd64

What did you do?

GOFLAGS='=' gotip env
GOFLAGS='-trimpath =' gotip env
GOFLAGS='= -trimpath' gotip env

What did you expect to see?

go: parsing $GOFLAGS: non-flag "="

What did you see instead?

panic: runtime error: slice bounds out of range [1:0]

goroutine 1 [running]:
cmd/go/internal/base.SetFromGOFLAGS(0x195a938)
	/go/src/cmd/go/internal/base/goflags.go:101 +0x9a7
main.main()
	/go/src/cmd/go/main.go:188 +0x755
tie added a commit to tie/genji that referenced this issue Oct 16, 2020
tie added a commit to tie/genji that referenced this issue Oct 16, 2020
@bcmills bcmills added this to the Backlog milestone Oct 16, 2020
@bcmills bcmills added the GoCommand label Oct 16, 2020
@bcmills
Copy link
Member

@bcmills bcmills commented Oct 16, 2020

Neat find! Thanks for the report.

@obeyda
Copy link
Contributor

@obeyda obeyda commented Oct 16, 2020

Hello, can I help on this issue?

@bcmills
Copy link
Member

@bcmills bcmills commented Oct 16, 2020

@obeyda, sure! Start with a new test case replicating the panic in src/cmd/go/testdata/script.

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 16, 2020

Change https://golang.org/cl/263098 mentions this issue: cmd/go: add flag name check for GOFLAGS entries

@obeyda
Copy link
Contributor

@obeyda obeyda commented Oct 16, 2020

On second thought, I think it would make more sense to silently ignore the bad flag instead of showing an error, since this only happens in env and bug commands, and these commands are used when debugging...
see comment on: https://go.googlesource.com/go/+/refs/heads/master/src/cmd/go/internal/base/goflags.go#40

@bcmills
Copy link
Member

@bcmills bcmills commented Oct 16, 2020

Yep. When hideErrors is false, InitGOFLAGS should report the invalid flags, so SetFromGOFLAGS can ignore invalid flags unconditionally. (Either the error has already been reported in InitGOFLAGS, or we don't care to report it at all.)

tie added a commit to tie/genji that referenced this issue Oct 19, 2020
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
4 participants
You can’t perform that action at this time.