-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: encoded pkg path shown in stack trace #35558
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
Comments
It seems like the compiler is doing this. I was able to reproduce this back as far as 1.11. Here's a simpler test case that shows
@cherrymui @randall77 @aclements Is this a bug or intended behavior? |
Yeah, this is just the symbol name in the binary. The symbol names are escaped to avoid collisions as well as other problems. We never document or guarantee how the symbol names are constructed, although we try to make it readable and close to the identifier in the source code. Gccgo constructs symbol names differently.
I would say this is an implementation detail that happens to be this way.
Yeah. Before 1.13 the compiler writes "" and the linker expands to the same escaped name. |
@cherrymui Escaping symbol names in compiled code makes sense to me, but can we unescape those names in stack traces? |
We could tweak the names in stack traces, but the question is: which choice is more confusing? For example, do people expect to be able to match the symbol names shown in stack traces to the symbol names reported by |
I suspect very few people are running |
It's exactly because few people run |
Hmm. That assumes the user's mental model is that the stack trace contains binary symbols, as opposed to something at the level of language semantics like package paths and function/method names. This makes perfect sense to us as compiler authors, but I doubt many users think of it this way. Indeed, we go to some trouble to make the stack traces match language semantics rather than implementation details: eliding wrapper functions, rewriting names of some runtime functions, etc. All of our binary symbols on Darwin start with an underscore, but we don't print that in the stack trace. That said, our symbols are so lightly escaped right now that we can just have our cake and eat it, too, and only occasionally find a bit of egg shell. We might as well err on the side of printing the symbol name since that will confuse basically no one (though it may surprise, as demonstrated by this bug report!) and will help the few people for whom it is better to have the raw symbol name. I do wonder if generics will change this, if we use a stenciling implementation. If our symbols become significantly more mangled (say, like C++ symbols, though hopefully not that bad), I absolutely think it would be more meaningful to show something semantic in a stack trace over a mangled symbol name. |
The rule here (only escape dots after the final slash in the package path) was chosen deliberately as something that would only very rarely arise. You can make up examples like creating github.com/rsc/p (a repo) containing directories q and q.r, where q defines type r with value method m and q.r defines function m. Then "github.com/rsc/p/q.r.m" is ambiguous, and the root cause is you can't identify which dot is the package-dot-name dot. Unescaping the stack trace would make it ambiguous, but I think that's probably the right thing to do. The %2e is not something users understand how to read. Fixing the stack traces would probably imply changing the result of runtime.Func.Name to return an unescaped string (meaning we'd just store the unescaped one in the func table in the binary to begin with). On the other hand, the case is by design rare - it basically only affects gopkg.in. Waiting to see what happens with generics seems like a good idea. It may be that we decide Func.Name should return ambiguous names, because you don't want to see all the detail about specific type parameters in the stack traces. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run the following
testscript
repro:What did you expect to see?
What did you see instead?
Note the
%2e
in the stack trace.cc @bcmills @randall77 @jayconrod
The text was updated successfully, but these errors were encountered: