Skip to content

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

@stevemk14ebr

Description

@stevemk14ebr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions