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
doc/go1.17: document closure inlining affects function PC comparison #45781
Comments
cc @danscales for inlining closures. This is working as intended. We probably need to document it better. |
|
Comparing PCs of functions is never intended to work (e.g. |
heh, I'm surprised we got away with it for so many go versions then. Thanks for the quick response, I'll replace the code with something less brittle. |
@cherrymui Do you know where a good place to document this might be? |
I think it's better in the release notes. @danscales may already have a CL. |
@danscales, if you don't mind I'll make you an assignee on this issue, but please feel free to update it if you're not able to get to this. |
I already sent this text to Jeremy about a week ago: Functions containing closures can now be inlined. One effect of this change is that a function returning a constant closure may actually return a different closure function for each place that it is inlined. Hence, this change could reveal bugs where Go functions are compared (incorrectly) by (unsafe) pointer value. Go functions are by definition not comparable. Is there a place that I should put this in the release notes (I'm not sure how to do it), or @cherrymui do you want to just grab it (since I think you are collecting release notes). |
Thank you Dan. We can probably place that as a paragraph in the Runtime section at https://tip.golang.org/doc/go1.17#runtime. The corresponding file is here: Lines 214 to 222 in 217f5dd
|
Change https://golang.org/cl/322089 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
only master
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/Yw1lgRph4Kd
What did you expect to see?
This should print
main.WithFoo.func1
, as with go 16.3What did you see instead?
After the regabi branch merge, this prints
main.init.func1
This was temporarily fixed by 1129a60, which disabled inlining of functions that contain closures.
The text was updated successfully, but these errors were encountered: