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/buildid: crashes trying to write buildid in binary built by Go 1.5 #50809

Closed
stevemk14ebr opened this issue Jan 25, 2022 · 2 comments
Closed

cmd/buildid: crashes trying to write buildid in binary built by Go 1.5 #50809

stevemk14ebr opened this issue Jan 25, 2022 · 2 comments
Labels
NeedsFix
Milestone

Comments

@stevemk14ebr
Copy link
Contributor

@stevemk14ebr stevemk14ebr commented Jan 25, 2022

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

1.17.2 linux/amd64

$ go version
1.17.2 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

linux

go env Output
$ go env

What did you do?

run go tool buildid -w <filepath> on a go 1.5 binary and the following error will occur:

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

goroutine 1 [running]:
main.main()
        /usr/local/go/src/cmd/buildid/buildid.go:56 +0x60d

The line:

newID := id[:strings.LastIndex(id, "/")] + "/" + buildid.HashToString(hash)

This is because in go 1.5 the contentID did not exist, so the slash seperator is not present, causing issues. The buildid tool doesn't consider legacy buildID/actionID/contentID layouts.

What did you expect to see?

The buildID / contentID to be written

What did you see instead?

crash

@ianlancetaylor ianlancetaylor changed the title affected/package: go tool buildid cmd/buildid: crashes trying to write buildid in binary built by Go 1.5 Jan 25, 2022
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 25, 2022

Also fails with Go 1.6 through Go 1.9. Go 1.10 and later seem to work.

Those older versions of Go are not supported. If someone wants to contribute a fix that would be fine but I don't think we are going to actively work on this.

@ianlancetaylor ianlancetaylor added the NeedsInvestigation label Jan 25, 2022
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Jan 25, 2022
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 3, 2022

Change https://go.dev/cl/409535 mentions this issue: cmd/buildid: reject rewriting legacy buildids

@dmitshur dmitshur added NeedsFix and removed NeedsInvestigation labels Jun 6, 2022
@dmitshur dmitshur removed this from the Unplanned milestone Jun 6, 2022
@dmitshur dmitshur added this to the Go1.19 milestone Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix
Projects
None yet
4 participants