Description
Given a single file main.go in a module:
package main
import "golang.org/x/text/search"
func main() {
var p search.Pattern
x, y := p.Index(nil, search.Backwards) // Deliberate panic here.
println(x, y)
}
With go version go1.13.6 darwin/amd64
, after running go mod vendor
, then go run -mod=vendor -trimpath main.go
returns the following output:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x10a9cbc]
goroutine 1 [running]:
golang.org/x/text/search.(*Pattern).Index(0xc000076f30, 0x0, 0x0, 0x0, 0xc000076f1f, 0x1, 0x1, 0xc000042750, 0xc000076f50)
golang.org/x/[email protected]/search/search.go:177 +0x9c
main.main()
example.com/trimpath@/main.go:7 +0x7f
exit status 2
Notice that the location is printed as golang.org/x/text@v0...
.
With go tip at go version devel +71154e061f Tue Jan 14 17:13:34 2020 +0000 darwin/amd64
, running go run -mod=vendor -trimpath main.go
produces this output:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x10ad40c]
goroutine 1 [running]:
golang.org/x/text/search.(*Pattern).Index(0xc000096f58, 0x0, 0x0, 0x0, 0xc000096f47, 0x1, 0x1, 0xc000044778, 0xc000096f78)
/tmp/x/vendor/golang.org/x/text/search/search.go:177 +0x9c
main.main()
example.com/trimpath@/main.go:7 +0x7e
exit status 2
Notice that now, the vendored module has changed to its absolute path on disk, /tmp/x/vendor/...
.
I bisected to 6cba4db as the commit which introduced this path-based output.
$ gotip version && gotip run -mod=vendor -trimpath main.go
go version devel +1736f3a126 Wed Oct 9 18:12:31 2019 +0000 darwin/amd64
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x10a4acc]
goroutine 1 [running]:
golang.org/x/text/search.(*Pattern).Index(0xc000076f30, 0x0, 0x0, 0x0, 0xc000076f1f, 0x1, 0x1, 0xc000042750, 0xc000076f50)
golang.org/x/[email protected]/search/search.go:177 +0x9c
main.main()
example.com/trimpath@/main.go:7 +0x7e
exit status 2
$ gotip version && gotip run -mod=vendor -trimpath main.go
go version devel +6cba4dbf80 Wed Oct 9 18:39:22 2019 +0000 darwin/amd64
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x10a4acc]
goroutine 1 [running]:
golang.org/x/text/search.(*Pattern).Index(0xc000076f30, 0x0, 0x0, 0x0, 0xc000076f1f, 0x1, 0x1, 0xc000042750, 0xc000076f50)
/tmp/x/vendor/golang.org/x/text/search/search.go:177 +0x9c
main.main()
example.com/trimpath@/main.go:7 +0x7e
exit status 2
With the new behavior since 6cba4db, -trimpath no longer works as documented in go help build
("remove all file system paths from the resulting executable").
/cc @bcmills @jayconrod