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 when computing Shlib path for a test-only package #35759

Closed
bcmills opened this issue Nov 21, 2019 · 4 comments
Closed

cmd/go: panic when computing Shlib path for a test-only package #35759

bcmills opened this issue Nov 21, 2019 · 4 comments
Assignees
Labels
Milestone

Comments

@bcmills
Copy link
Member

@bcmills bcmills commented Nov 21, 2019

I discovered a panic while investigating #30316.

~/go/misc/cgo/testshared$ go version
go version devel +b3a35e026f Thu Nov 21 09:17:51 2019 -0500 linux/amd64

~/go/misc/cgo$ go list -f '{{.Shlib}}' -buildmode=shared -linkshared runtime sync/atomic .
can't load package: package .: no Go files in /usr/local/google/home/bcmills/go/misc/cgo
/usr/local/google/home/bcmills/go/pkg/linux_amd64_dynlink/libruntime,sync-atomic.so
/usr/local/google/home/bcmills/go/pkg/linux_amd64_dynlink/libruntime,sync-atomic.so

~/go/misc/cgo$ go list -f '{{.Shlib}}' -buildmode=shared -linkshared runtime sync/atomic ./testshared
panic: runtime error: slice bounds out of range [:-2]

goroutine 1 [running]:
cmd/go/internal/load.(*Package).load(0xc00009a480, 0xc0001bd390, 0xc000200700, 0x0, 0x0)
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/load/pkg.go:1588 +0x3675
cmd/go/internal/load.loadImport(0xc0000a4270, 0xc0000b4600, 0x13, 0xc00002a064, 0x2a, 0x0, 0xc0001bd390, 0x0, 0x0, 0x0, ...)
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/load/pkg.go:577 +0xef7
cmd/go/internal/load.PackagesAndErrors(0xc0000200f0, 0x3, 0x3, 0x0, 0x0, 0x0)
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/load/pkg.go:2079 +0x387
cmd/go/internal/load.Packages(0xc0000200f0, 0x3, 0x3, 0xc00017ee40, 0x0, 0x0)
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/load/pkg.go:2035 +0x5a
cmd/go/internal/list.runList(0xeaec20, 0xc0000200f0, 0x3, 0x3)
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/list/list.go:441 +0x231e
main.main()
        /usr/local/google/home/bcmills/go/src/cmd/go/main.go:189 +0x569

CC @ianlancetaylor @jayconrod

@bcmills bcmills added the NeedsFix label Nov 21, 2019
@bcmills bcmills added this to the Go1.14 milestone Nov 21, 2019
@bcmills bcmills self-assigned this Nov 21, 2019
@jayconrod

This comment has been minimized.

Copy link
Contributor

@jayconrod jayconrod commented Nov 21, 2019

Possible duplicate of #34347

@bcmills

This comment has been minimized.

Copy link
Member Author

@bcmills bcmills commented Nov 21, 2019

Ooh, nice find!

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 21, 2019

Change https://golang.org/cl/208233 mentions this issue: cmd/go: do not panic when computing Shlib for a package with no Target

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 22, 2019

Change https://golang.org/cl/208457 mentions this issue: cmd/go: add a 'buildmode' condition for script tests

gopherbot pushed a commit that referenced this issue Nov 22, 2019
In CL 208233 I am fixing a panic that occurs only with a specific
build mode. I want that test to run on all platforms that support that
build mode, but the logic for determining support is somewhat
involved.

For now, I am duplicating that logic into the cmd/internal/sys
package, which already reports platform support for other build flags.

We can refactor cmd/go/internal/work to use the extracted function in
a followup CL.

Updates #35759

Change-Id: Ibbaedde4d1e8f683c650beedd10849bc27e7a6e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/208457
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
@gopherbot gopherbot closed this in 941ac9c Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.