Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: go/defer call of external or //go:uintptrescapes function does not protect unsafe.Pointer arguments #38581
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.