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
runtime: bad stack trace when using mid-stack inlining #29007
Comments
This comment in traceback.go seems relevant:
Maybe there's another way to encode the required skips? |
The API has us rather backed into a corner here. Given that we only have 1 uintptr's worth of space to store information, it's not clear to me how we can store both the PC and the inlining level. |
Should this block the beta scheduled for next week? |
This could potentially mess up programs that use the log package, if the log package causes mid-stack inlining to occur. And it could potentially mess up other people's log packages as well. I think this probably does block the beta, unless we just give up on it. |
A possibility is to find and/or put an instruction that can be used to indicate the outer scope. So for instance:
We have assembly like (when
We could instead generate:
When we need to encode something that is just f, provide the address of that NOP. |
Then we'd need some info in |
If we need a side table anyhow, then we don't necessarily have to use an actual instruction in the function. We could use an address in the |
At the time we were designing the current solution, we wanted to give real PCs in case someone was using them as such (e.g., to look something up using |
The PC value returned by That sounds workable but fairly complicated, and it adds a cost to all mid-stack inlining. And of course it only matters for the very last entry in the PCs returned by We should at least consider simply documenting that programs that want to pick out a specific entry should increment the size of the array they pass to |
What does this mean, exactly? Are people printing the contents of Or are you referencing something programmatic? |
I was just quoting Austin. I don't really know what the restrictions are on the values we store in |
I was thinking of something different, which is to do the inlining expansion in Consider the code:
Where both Currently Instead I want to put an entry in the result of All three pcs would be in |
Related: #28640 (fixing wrapper elision when mid-stack inlining). |
@randall77 I see, that makes sense. That is basically what gccgo does. |
Change https://golang.org/cl/152537 mentions this issue: |
Change https://golang.org/cl/153241 mentions this issue: |
When functions are inlined, for instructions in the inlined body, does -S print the location of the call, or the location of the body? Right now, we do the former. I'd like to do the latter by default, it makes much more sense when reading disassembly. With mid-stack inlining enabled in more cases, this quandry will come up more often. The original behavior is still available with -S=2. Some tests use this mode (so they can find assembly generated by a particular source line). This helped me with understanding what the compiler was doing while fixing #29007. Change-Id: Id14a3a41e1b18901e7c5e460aa4caf6d940ed064 Reviewed-on: https://go-review.googlesource.com/c/153241 Reviewed-by: David Chase <drchase@google.com>
This program should print
main.main
. It does on Go 1.11, but not tip. On tip it printsmain.f
.Weirdly, if you declare
pcs
to be[2]uintptr
, then it works.It also works correctly with other skip parameters (1, 2 and 4 all work).
This bug is somehow related to the mid-stack inlining of
f
.@davidlazar @aclements
The text was updated successfully, but these errors were encountered: