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

x/tools/internal/analysisinternal: panic in IsTypeNamed #71456

Closed
adonovan opened this issue Jan 27, 2025 · 1 comment
Closed

x/tools/internal/analysisinternal: panic in IsTypeNamed #71456

adonovan opened this issue Jan 27, 2025 · 1 comment
Assignees
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Jan 27, 2025

Observed in https://ci.chromium.org/ui/p/golang/builders/ci/x_tools-gotip-darwin-amd64-longtest/b8726292744544624369/overview:

func IsTypeNamed(t types.Type, pkgPath string, names ...string) bool {
	if named, ok := types.Unalias(t).(*types.Named); ok {
		tname := named.Obj() <--- SIGSEGV
		return tname != nil &&
			isPackageLevel(tname) &&
			tname.Pkg().Path() == pkgPath &&
			slices.Contains(names, tname.Name())
	}
	return false
}

Looks like a nil *types.Named found its way into a types.Object.

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xe923009]

goroutine 86548 [running]:
golang.org/x/tools/gopls/internal/cache.(*action).exec.func7.1()
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/gopls/internal/cache/analysis.go:1196 +0x233
panic({0xf4470e0?, 0xfd673c0?})
	/Users/swarming/.swarming/w/ir/x/w/goroot/src/runtime/panic.go:787 +0x132
go/types.(*Named).Obj(...)
	/Users/swarming/.swarming/w/ir/x/w/goroot/src/go/types/named.go:308
golang.org/x/tools/internal/analysisinternal.IsTypeNamed({0xf5b9980?, 0x0?}, {0xf01bba6, 0x4}, {0xc036fcc998, 0x1, 0xe8b72e8?})
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/internal/analysisinternal/analysis.go:305 +0x89
golang.org/x/tools/internal/analysisinternal.IsMethodNamed({0xf5ccff8?, 0xc03cdf9200?}, {0xf01bba6, 0x4}, {0xf01c79a, 0x4}, {0xc036fccb00, 0x1, 0xc006f98808?})
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/internal/analysisinternal/analysis.go:339 +0xf8
golang.org/x/tools/go/analysis/passes/timeformat.run.func1({0xf5b9020?, 0xc0296d8140})
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/go/analysis/passes/timeformat/timeformat.go:53 +0xae
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0xc03b883950, {0xc036fccb90?, 0x13ae9eb8?, 0x13ae9eb806f98808?}, 0xc036fccba0)
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/go/ast/inspector/inspector.go:96 +0x8f
golang.org/x/tools/go/analysis/passes/timeformat.run(0xc00ffafc00)
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/go/analysis/passes/timeformat/timeformat.go:50 +0x8b
golang.org/x/tools/gopls/internal/cache.(*action).exec.func7(0xfd86400, 0xc036fccd48, 0xc00ffafc00, 0xc036fccd10)
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/gopls/internal/cache/analysis.go:1209 +0x97
golang.org/x/tools/gopls/internal/cache.(*action).exec(0xc03d2087e0, {0xf5be7c0, 0xc0347fca50})
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/gopls/internal/cache/analysis.go:1210 +0xb1c
golang.org/x/tools/gopls/internal/cache.execActions.func1.1()
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/gopls/internal/cache/analysis.go:909 +0x52
sync.(*Once).doSlow(0x0?, 0xc036fccf98?)
	/Users/swarming/.swarming/w/ir/x/w/goroot/src/sync/once.go:78 +0xab
sync.(*Once).Do(...)
	/Users/swarming/.swarming/w/ir/x/w/goroot/src/sync/once.go:69
golang.org/x/tools/gopls/internal/cache.execActions.func1()
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/gopls/internal/cache/analysis.go:907 +0x85
created by golang.org/x/tools/gopls/internal/cache.execActions in goroutine 86469
	/Users/swarming/.swarming/w/ir/x/w/targetrepo564898521/gopls/internal/cache/analysis.go:905 +0x55
FAIL	golang.org/x/tools/gopls/internal/test/integration/workspace	187.033s
@adonovan adonovan added the Analysis Issues related to static analysis (vet, x/tools/go/analysis) label Jan 27, 2025
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jan 27, 2025
@gopherbot gopherbot added this to the Unreleased milestone Jan 27, 2025
@adonovan adonovan self-assigned this Jan 27, 2025
@adonovan
Copy link
Member Author

Already fixed by @timothy-king in CL 641177.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants