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

Track goroutine pointer usage like unsafe pointers #28

Open
kalexmills opened this issue Nov 29, 2020 · 6 comments
Open

Track goroutine pointer usage like unsafe pointers #28

kalexmills opened this issue Nov 29, 2020 · 6 comments
Labels
enhancement New feature or request false-positive the issue can create a false-positive vet-bot the issue is part of VetBot's responsibility

Comments

@kalexmills
Copy link
Contributor

kalexmills commented Nov 29, 2020

The pointerescape analysis pass checks each pointer argument of each function call, whereas the nogofunc pass does not. Since we're already doing it for pointerescape, it would be simple to determine if a pointer argument is used during a goroutine and thread this information back through the callgraph like we do there.

That may or may not be needed, though. It depends how many false-positives that analyzer is picking up.

@kalexmills kalexmills added vet-bot the issue is part of VetBot's responsibility false-positive the issue can create a false-positive enhancement New feature or request labels Nov 29, 2020
@kalexmills kalexmills modified the milestone: go-nuts release Dec 1, 2020
@kalexmills
Copy link
Contributor Author

kalexmills commented Dec 25, 2020

github-vet/rangeloop-pointer-findings#7151 could potentially motivate this change. A constant was being passed to a logging function call, and it triggered nogofunc. Very sad.

@kalexmills kalexmills added this to the General Availability milestone Dec 25, 2020
@kalexmills
Copy link
Contributor Author

kalexmills commented Dec 25, 2020

Right now, I'm thinking that the large graphs found in issues like this one would motivate this change.

github-vet/rangeloop-pointer-findings#8109

@kalexmills
Copy link
Contributor Author

#101 may obviate the need for this.

@kalexmills
Copy link
Contributor Author

kalexmills commented Dec 26, 2020

best-case scenario: we start checking each function that starts a goroutine and accepts a pointer using an analysis very much like loopclosure, exchanging range-loop variables for pointer arguments. This would tell us if the pointer argument is actually referred to inside the goroutine.

Actually; the above idea can be implemented separately from this ticket to weed out functions which start a goroutine but don't refer to any of their pointer arguments within the goroutine call.

@kalexmills
Copy link
Contributor Author

#110 should be done first; since it's simpler.

@kalexmills kalexmills removed this from the General Availability milestone Dec 26, 2020
@kalexmills
Copy link
Contributor Author

This is actually much simpler than I thought.

Pointerescapes already checks third-party code and code that writes a pointer. It's simple to have it check to see whether a pointer is used inside a goroutine as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request false-positive the issue can create a false-positive vet-bot the issue is part of VetBot's responsibility
Projects
None yet
Development

No branches or pull requests

1 participant