You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is caused by inlining. I don’t believe there is a bug here.
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.
I don't think this has anything directly to do with inlining. It's just that in
func f() {
go g()
}
f is not the caller of g. At least, not according to the runtime. For instance, the stack frame of f can be long gone while g is still running.
The caller of the function g is goexit. That's just a placeholder, we could just as well have decided that g doesn't have a caller. But goexit makes it clear that when g returns, the goroutine is going to exit (ala runtime.Goexit).
If you want to know where a goroutine was spawned from, that information is available in the output of runtime.Stack.
What I want to do is to create a helper function to track caller in log without any injection code. After investigation, I did find runtime.Stack could do the trick, but somehow it is not elegant, and also performance.
It could be better to have a new function to get the spawner.
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?
get caller of some func
https://play.golang.org/p/gKjf1xNTCOK
What did you expect to see?
see the correct caller
What did you see instead?
for func called in goroutine mode, the caller is
goexit
The text was updated successfully, but these errors were encountered: