-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
debug/gosym: Sym.PackageName provides the wrong result #66313
Comments
I also test it with some other popular golang project like k8s. For https://github.com/Zxilly/go-testdata/releases/download/kube/kubelet-linux-1.22-amd64, we got
I suspect that something triggers a special rule at link time that adds an extra module name to the embedded receiver for identification purposes, but I can't find the exact code that adds the corresponding package name to the receiver, so I can't confirm that this is the actual behaviour occurring, and therefore can't write a patch that fixes the bug. I would appreciate any help from anyone familiar with the linker codebase. |
It seems to me we now are adding package paths to some of the methods (maybe just unexported methods? embedded methods?), which is unexpected to me. I think it probably occurs in the compiler, not the linker. |
I agree with you, Another point of note is that when I look at the source file for these functions using |
Yeah, for embedded methods, the compiler creates wrapper methods on the outer type. |
That's my guess too, but I can't reproduce it on a smaller example, do you have one of those? |
If possible, I think we may need to change the rules for generating the symbol name. Because things like this also happen with non-pointer receivers. For something like |
Change https://go.dev/cl/572076 mentions this issue: |
cc @golang/compiler |
We package-prefix unexported promoted methods that were declared in another package. Something like this should produce prefixed method name:
|
I was wondering if this issue might be fixed in go1.23 |
@mdempsky What do you think of https://go-review.googlesource.com/c/go/+/572076? |
Go version
go version go1.22.0 windows/amd64
Output of
go env
in your module/workspace:What did you do?
In some edge cases, Sym.PackageName will provide incorrect results.
I'm sorry I couldn't provide a minimally reproducible sample. But you can find a sample at https://github.com/ZNotify/server/releases/download/test/analysis-server-linux.
I use the follow code to identify the wrong output.
What did you see happen?
With the script above, I get the follow output
What did you expect to see?
The correct package for these names should be
The text was updated successfully, but these errors were encountered: