Skip to content
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

cmd/compile: go/defer call of external or //go:uintptrescapes function does not protect unsafe.Pointer arguments #38581

Closed
mdempsky opened this issue Apr 22, 2020 · 1 comment
Labels
Milestone

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Apr 22, 2020

This test program currently prints "ok FAIL FAIL ok ok": https://play.golang.org/p/KEf2cpdL_mA

@ianlancetaylor and I think unsafe.Pointer's safety rule 4 requires it to print "ok ok ok ok ok". Probably by rewriting the 2nd and 3rd call forms into the 4th and 5th, respectively.

We already have a similar rewrite for handling "go builtin(...)" and "defer builtin(...)", but that doesn't happen until "walk", but currently we handle keepalive in "order". We also handle //go:uintptrescapes calls in escape analysis, so it would be nice to rewrite before then too... except escape analysis is currently responsible for marking //go:uintptrescapes and "unsafe uintptr" assembly parameters.

Low priority. Not known to affect any real world code at the moment. I discovered this while exploring possible frontend simplification work.

@mdempsky mdempsky added the NeedsFix label Apr 22, 2020
@mdempsky mdempsky added this to the Unplanned milestone Apr 22, 2020
@mdempsky
Copy link
Member Author

@mdempsky mdempsky commented Apr 22, 2020

@cuonglm points out this is a duplicate of #24491.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.