-
Notifications
You must be signed in to change notification settings - Fork 2.3k
internal/lsp/cache: fix leaking wg.Done() and <-ioLimit #107
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
Conversation
Fixes golang/go#32368 There were several returns in this function that could leak both the wg.Done() and <-ioLimit. This refactors them into defers close to their counterparts. Additionally I refactored the function to favor early returns over nested if statements.
PS: This may fix golang/go#32368, but there may be other things going on elsewhere that also need to be addressed. |
This PR (HEAD: c4c8686) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/tools/+/179878 to see it. Tip: You can toggle comments from me using the |
Message from Rebecca Stambler: Patch Set 1: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Gobot Gobot: Patch Set 1: TryBots beginning. Status page: https://farmer.golang.org/try?commit=75e6cc47 Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Ian Cottrell: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Rebecca Stambler: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Gobot Gobot: Patch Set 1: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
This PR (HEAD: cd31933) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/tools/+/179878 to see it. Tip: You can toggle comments from me using the |
Message from Edward Muller: Patch Set 1:
Re nil vs len()==0 The error returned is "No source for %v", which is true in either case. I'm happy to restore the nil check though instead, let me know. Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Edward Muller: Patch Set 2:
I capitalized AND on purpose to bring attention to it. Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Edward Muller: Patch Set 2: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
As per Ian Cottrell's review comments. I did it the way I did originally so at to not appear to couple the two things together for future readers, but it doesn't really matter to me. Revert the len() == 0 check to a nil check. Change-Id: I77376a5e2b10ad563a37ca3aa3e53f928e577e2d
Message from Ian Cottrell: Patch Set 2:
Where possible we want the errors to match what you would see on the command line, so if the parser can cope it should be left to it. Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
This PR (HEAD: bfa160b) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/tools/+/179878 to see it. Tip: You can toggle comments from me using the |
Message from Edward Muller: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Ian Cottrell: Patch Set 5: Run-TryBot+1 Code-Review+2 Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Gobot Gobot: Patch Set 5: TryBots beginning. Status page: https://farmer.golang.org/try?commit=d9336d4c Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Ian Cottrell: Patch Set 5: Thanks a lot for looking in to this and well found! Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Gobot Gobot: Patch Set 5: TryBot-Result-1 1 of 10 TryBots failed: Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Edward Muller: Patch Set 5: Related to this... I was looking into some of the methods used inside of this function and noticed that *goFile.read()'s documentation says: "It assumes that the caller is holding the mutex of the file's view.", but clearly this function is not, nor does *importer.typeCheck() (the only caller of *importer.parseFiles() I can find), but *importer.getPkg() does take locks on *importer's view.pcache.mu, but those aren't held during the call to typeCheck. Does this comment need to be updated? Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
Message from Rebecca Stambler: Patch Set 5:
loadParseTypecheck is always called from one of the 3 GetToken, GetAST, or GetPackage functions, which grab the file's view's mutex at the start (see tools/internal/lsp/cache/gofile.go Line 22 in b3315ee
Please don’t reply on this GitHub thread. Visit golang.org/cl/179878. |
There were several returns in this function that could leak both the wg.Done() and <-ioLimit. This refactors them into defers close to their counterparts. Additionally I refactored the function to favor early returns over nested if statements. Fixes golang/go#32368 Change-Id: I5357d11ee526c1cb7a6bd1a0f652c61d574c10ab GitHub-Last-Rev: bfa160b GitHub-Pull-Request: #107 Reviewed-on: https://go-review.googlesource.com/c/tools/+/179878 Reviewed-by: Ian Cottrell <[email protected]> Run-TryBot: Ian Cottrell <[email protected]>
This PR is being closed because golang.org/cl/179878 has been merged. |
There were several returns in this function that could leak both the
wg.Done() and <-ioLimit. This refactors them into defers close to their
counterparts.
Additionally I refactored the function to favor early returns over
nested if statements.
Fixes golang/go#32368