Skip to content

go/types: panic: invalid package name "_" #20231

Closed
@josharian

Description

@josharian
package p
	
import "_"

Check with go/types, using Config:

	conf := types.Config{
		Error:    func(err error) {}, // important for reproduction
	}

Result is panic while executing conf.Check:

panic: invalid package name _ [recovered]
	panic: invalid package name _ [recovered]
	panic: invalid package name _

goroutine 18 [running]:
testing.tRunner.func1(0xc4200f80f0)
	/Users/josh/go/tip/src/testing/testing.go:712 +0x256
panic(0x12914e0, 0x1334390)
	/Users/josh/go/tip/src/runtime/panic.go:489 +0x259
go/types.(*Checker).handleBailout(0xc4200fa000, 0xc420071d18)
	/Users/josh/go/tip/src/go/types/check.go:225 +0xa4
panic(0x12914e0, 0x1334390)
	/Users/josh/go/tip/src/runtime/panic.go:489 +0x259
go/types.NewPackage(0xc420088391, 0x1, 0xc420088391, 0x1, 0xffffffffffffffff)
	/Users/josh/go/tip/src/go/types/package.go:27 +0x439
go/types.(*Checker).importPackage(0xc4200fa000, 0x15, 0xc420088391, 0x1, 0x12f52f4, 0x1, 0x9)
	/Users/josh/go/tip/src/go/types/resolver.go:172 +0x460
go/types.(*Checker).collectObjects(0xc4200fa000)
	/Users/josh/go/tip/src/go/types/resolver.go:243 +0x1c04
go/types.(*Checker).checkFiles(0xc4200fa000, 0xc420046e30, 0x1, 0x1, 0x0, 0x0)
	/Users/josh/go/tip/src/go/types/check.go:237 +0xa1
go/types.(*Checker).Files(0xc4200fa000, 0xc420046e30, 0x1, 0x1, 0xc420080c90, 0x0)
	/Users/josh/go/tip/src/go/types/check.go:230 +0x49
go/types.(*Config).Check(0xc42008ab80, 0x12f531e, 0x1, 0xc42008ab00, 0xc420046e30, 0x1, 0x1, 0xc4200955e0, 0x0, 0x1, ...)
	/Users/josh/go/tip/src/go/types/api.go:351 +0x1b3
go/types_test.TestIssue16902(0xc4200f80f0)
	/Users/josh/go/tip/src/go/types/sizes_test.go:102 +0x2ad
testing.tRunner(0xc4200f80f0, 0x130bc80)
	/Users/josh/go/tip/src/testing/testing.go:747 +0xd0
created by testing.(*T).Run
	/Users/josh/go/tip/src/testing/testing.go:789 +0x2de
exit status 2

Discovered with go-fuzz.

@griesemer @mvdan

Activity

gopherbot

gopherbot commented on May 5, 2017

@gopherbot
Contributor

CL https://golang.org/cl/42852 mentions this issue.

locked and limited conversation to collaborators on May 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @josharian@gopherbot

        Issue actions

          go/types: panic: invalid package name "_" · Issue #20231 · golang/go