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

import/path: issue title #70442

Closed
kms9 opened this issue Nov 19, 2024 · 2 comments
Closed

import/path: issue title #70442

kms9 opened this issue Nov 19, 2024 · 2 comments

Comments

@kms9
Copy link

kms9 commented Nov 19, 2024

Go version

go version go1.23.3 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/logo/Library/Caches/go-build'
GOENV='/Users/logo/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/logo/go/pkg/mod'
GONOPROXY='gitlab.yc345.tv'
GONOSUMDB='gitlab.yc345.tv'
GOOS='darwin'
GOPATH='/Users/logo/go'
GOPRIVATE='gitlab.yc345.tv'
GOPROXY='https://goproxy.cn'
GOROOT='/Users/logo/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/logo/go/pkg/mod/golang.org/[email protected]/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.3'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/logo/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/logo/gocode/backend/ast-trace-graph/ai_tag/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/yw/k8drw3x52_j3z401tt505xl00000gn/T/go-build2846703051=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

// 配置并加载包
	cfg := &packages.Config{
		Mode: packages.LoadAllSyntax,
		Dir:  projectPath,
	}
	pkgs, err := packages.Load(cfg, "./...")
	//pkgs, err := packages.Load(cfg, "./")
	if err != nil {
		fmt.Printf("Failed to load program: %s\n", err)
		return
	}

	// 创建 SSA 程序
	prog, packagesAll := ssautil.Packages(pkgs, ssa.SanityCheckFunctions)
	_ = packagesAll
	prog.Build()
	allPackages := prog.AllPackages()
	// 基于指针分析方法生成调用图
	mains, err := mainPackages(allPackages)
	if err != nil {
		fmt.Printf("Failed to find main packages: %s\n", err)
		return
	}
	config := &pointer.Config{
		Mains:          mains,
		BuildCallGraph: true,
	}
	ptares, err := pointer.Analyze(config)
	if err != nil {
		fmt.Printf("Failed to build call graph: %s\n", err)
		return
	}
	cg := ptares.CallGraph

// 创建函数调用映射
funcCalls := make(map[*ssa.Function][]*ssa.Function)
visitFunc := func(edge *callgraph.Edge) error {
caller := edge.Caller.Func
callee := edge.Callee.Func

// 获取 caller 和 callee 的文件路径
posCaller := prog.Fset.Position(caller.Pos())
posCallee := prog.Fset.Position(callee.Pos())

callerFile := posCaller.Filename
calleeFile := posCallee.Filename

// 打印所有函数调用关系
fmt.Printf("%s -> %s\n", caller.Name(), callee.Name())
// 判断 caller 和 callee 是否在项目目录下
if !strings.HasPrefix(callerFile, absProjectPath) || !strings.HasPrefix(calleeFile, absProjectPath) {
	return nil
}

// 忽略标准库和接口调用
if inStdCached(caller) || inStdCached(callee) || isInter(edge) {
	return nil
}

// 添加到函数调用映射
funcCalls[caller] = append(funcCalls[caller], callee)
return nil
}
callgraph.GraphVisitEdges(cg, visitFunc)

What did you see happen?

API server listening at: 127.0.0.1:50435
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1500.0.22.8
 for arm64.
Got a connection, launched process /Users/logo/Library/Caches/JetBrains/GoLand2024.1/tmp/GoLand/___go_build_trace1 (pid = 6059).
WARNING: undefined behavior - version of Delve is too old for Go version go1.23.3 (maximum supported version 1.22)
Internal panic in pointer analysis:
goroutine 1 [running]:
runtime/debug.Stack()
        /Users/logo/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:26 +0x64
runtime/debug.PrintStack()
        /Users/logo/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:18 +0x1c
golang.org/x/tools/go/pointer.Analyze.func1()
        /Users/logo/go/pkg/mod/golang.org/x/tools/go/[email protected]/analysis.go:225 +0x168
panic({0x1029b79a0?, 0x102bb6920?})
        /Users/logo/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:785 +0xf0
golang.org/x/tools/go/ssa.(*Function).Type(0x0)
        /Users/logo/go/pkg/mod/golang.org/x/[email protected]/go/ssa/ssa.go:1558 +0x18
golang.org/x/tools/go/pointer.(*analysis).valueNode(0x14025a7e000, {0x102a0efa0, 0x0})
        /Users/logo/go/pkg/mod/golang.org/x/tools/go/[email protected]/gen.go:234 +0x144
golang.org/x/tools/go/pointer.(*analysis).genMethodsOf(0x14025a7e000, {0x102a0cc88, 0x14000134070})
        /Users/logo/go/pkg/mod/golang.org/x/tools/go/[email protected]/gen.go:1297 +0xd4
golang.org/x/tools/go/pointer.(*analysis).generate(0x14025a7e000)
        /Users/logo/go/pkg/mod/golang.org/x/tools/go/[email protected]/gen.go:1336 +0x260
golang.org/x/tools/go/pointer.Analyze(0x14025a548c0)
        /Users/logo/go/pkg/mod/golang.org/x/tools/go/[email protected]/analysis.go:290 +0xd50
main.CallGraphV2({0x1400011e180, 0x31})
        /Users/logo/gocode/backend/ast-trace-graph/trace1/main.go:95 +0x53c
main.main()
        /Users/logo/gocode/backend/ast-trace-graph/trace1/main.go:43 +0x208
Failed to build call graph: internal error in pointer analysis: runtime error: invalid memory address or nil pointer dereference (please report this bug)
Exiting.

What did you expect to see?

Correct output or explicit error reporting, not panic

@seankhliao
Copy link
Member

that looks like a delve issue, and it's quite clear on why:

version of Delve is too old for Go version go1.23.3 (maximum supported version 1.22)
Internal panic in pointer analysis:

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants