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

x/tools/gopls: crash in commonDir with filepath case differences #43520

Closed
samj7792 opened this issue Dec 31, 2020 · 7 comments
Closed

x/tools/gopls: crash in commonDir with filepath case differences #43520

samj7792 opened this issue Dec 31, 2020 · 7 comments

Comments

@samj7792
Copy link

@samj7792 samj7792 commented Dec 31, 2020

gopls version: v0.6.1
gopls flags:
extension version: 0.20.1
environment: Visual Studio Code

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

Saving file causes glitched imports. To be honest I'm not totally sure.

Please attach the stack trace from the crash.
A window with the error message should have popped up in the lower half of your screen.
Please copy the stack trace and error messages from that window and paste it in this issue.

[Info - 9:06:24 AM] 2020/12/31 09:06:24 go/packages.Load snapshot=0 directory=/Users/samueljackson/Documents/Code/SJ/redux query=[builtin github.com/t1cg/SJ/redux/...] packages=11

[Error - 9:06:24 AM] 2020/12/31 09:06:24 creating workspace dir: mkdir /var/folders/vg/4t5qpjw57jx1rtfbd46t0dxw0000gn/T/gopls-3749.workspace: file exists

[Error - 9:06:24 AM] 2020/12/31 09:06:24 unable to compute error positions: no parsed file for file:///Users/samueljackson/Documents/Code/SJ/redux/api/customfunctions/post_login.go in github.com/t1cg/SJ/redux/api/customfunctions
package="github.com/t1cg/SJ/redux/api/customfunctions"

golist_overlay.go:451: commonDir saw map[/Users/samueljackson/Documents/Code/SJ/redux/api/customFunctions:true /Users/samueljackson/Documents/Code/SJ/redux/api/customfunctions:true] for [/Users/samueljackson/Documents/Code/SJ/redux/api/customfunctions/get_record.go /Users/samueljackson/Documents/Code/SJ/redux/api/customfunctions/get_records.go /Users/samueljackson/Documents/Code/SJ/redux/api/customfunctions/post_register.go /Users/samueljackson/Documents/Code/SJ/redux/api/customFunctions/post_login.go]
[Error - 9:06:24 AM] Connection to server got closed. Server will not be restarted.
[Error - 9:06:24 AM] Request textDocument/documentSymbol failed.
Error: Connection got disposed.
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:94609:27)
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:10537:35)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12816:42)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:67230:15)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12803:18)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93821:26)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at StreamMessageReader.fireClose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93208:27)
at Socket. (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93293:42)
at Socket.emit (events.js:228:7)
at Pipe. (net.js:664:12)
[Error - 9:06:24 AM] Request textDocument/codeAction failed.
Error: Connection got disposed.
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:94609:27)
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:10537:35)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12816:42)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:67230:15)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12803:18)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93821:26)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at StreamMessageReader.fireClose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93208:27)
at Socket. (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93293:42)
at Socket.emit (events.js:228:7)
at Pipe. (net.js:664:12)
[Error - 9:06:24 AM] Request textDocument/documentLink failed.
Error: Connection got disposed.
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:94609:27)
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:10537:35)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12816:42)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:67230:15)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12803:18)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93821:26)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at StreamMessageReader.fireClose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93208:27)
at Socket. (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93293:42)
at Socket.emit (events.js:228:7)
at Pipe. (net.js:664:12)
[Error - 9:06:24 AM] Request textDocument/foldingRange failed.
Error: Connection got disposed.
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:94609:27)
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:10537:35)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12816:42)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:67230:15)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12803:18)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93821:26)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at StreamMessageReader.fireClose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93208:27)
at Socket. (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93293:42)
at Socket.emit (events.js:228:7)
at Pipe. (net.js:664:12)
[Error - 9:06:24 AM] Request textDocument/codeLens failed.
Error: Connection got disposed.
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:94609:27)
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:10537:35)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12816:42)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:67230:15)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12803:18)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93821:26)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at StreamMessageReader.fireClose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93208:27)
at Socket. (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93293:42)
at Socket.emit (events.js:228:7)
at Pipe. (net.js:664:12)
[Error - 9:06:24 AM] Request textDocument/codeLens failed.
Error: Connection got disposed.
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:94609:27)
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:10537:35)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12816:42)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:67230:15)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12803:18)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93821:26)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at StreamMessageReader.fireClose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93208:27)
at Socket. (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93293:42)
at Socket.emit (events.js:228:7)
at Pipe. (net.js:664:12)
[Error - 9:06:24 AM] Request textDocument/codeAction failed.
Error: Connection got disposed.
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:94609:27)
at Object.dispose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:10537:35)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12816:42)
at LanguageClient.handleConnectionClosed (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:67230:15)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:12803:18)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at closeHandler (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93821:26)
at CallbackList.invoke (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22491:39)
at Emitter.fire (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:22553:36)
at StreamMessageReader.fireClose (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93208:27)
at Socket. (/Users/samueljackson/.vscode/extensions/golang.go-0.20.1/dist/goMain.js:93293:42)
at Socket.emit (events.js:228:7)
at Pipe. (net.js:664:12)

Failed to auto-collect gopls trace: unrecognized crash pattern.

OPTIONAL: If you would like to share more information, you can attach your complete gopls logs.

NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE.
DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.

<OPTIONAL: ATTACH LOGS HERE>

@hyangah
Copy link
Contributor

@hyangah hyangah commented Jan 4, 2021

@samj7792 Thank you so much for sharing the trace.

@stamblerre @findleyr It's still not clear what causes the connection between vscode and gopls to be disposed yet. Can you please help checking

  • whether the following condition was the root cause or a side-effect of repeated crash&restart
  • whether this is a fatal error or not. From the code (session.go and check.go they don't look like a fatal error, but I don't know if this error later causes other problems in following operations.
[Info - 9:06:24 AM] 2020/12/31 09:06:24 go/packages.Load snapshot=0 directory=/Users/samueljackson/Documents/Code/SJ/redux query=[builtin github.com/t1cg/SJ/redux/...] packages=11

[Error - 9:06:24 AM] 2020/12/31 09:06:24 creating workspace dir: mkdir 
/var/folders/vg/4t5qpjw57jx1rtfbd46t0dxw0000gn/T/gopls-3749.workspace: file exists

[Error - 9:06:24 AM] 2020/12/31 09:06:24 unable to compute error positions: no parsed file for 
file:///Users/samueljackson/Documents/Code/SJ/redux/api/customfunctions/post_login.go in 
github.com/t1cg/SJ/redux/api/customfunctions
package="github.com/t1cg/SJ/redux/api/customfunctions"

golist_overlay.go:451: commonDir saw map[/Users/samueljackson/Documents/Code/SJ/redux/api/customFunctions:true 
/Users/samueljackson/Documents/Code/SJ/redux/api/customfunctions:true] for 
[/Users/samueljackson/Documents/Code/SJ/redux/api/customfunctions/get_record.go 
/Users/samueljackson/Documents/Code/SJ/redux/api/customfunctions/get_records.go 
/Users/samueljackson/Documents/Code/SJ/redux/api/customfunctions/post_register.go 
/Users/samueljackson/Documents/Code/SJ/redux/api/customFunctions/post_login.go]

[Error - 9:06:24 AM] Connection to server got closed. Server will not be restarted.
@findleyr
Copy link
Contributor

@findleyr findleyr commented Jan 4, 2021

2020/12/31 09:06:24 creating workspace dir: mkdir
/var/folders/vg/4t5qpjw57jx1rtfbd46t0dxw0000gn/T/gopls-3749.workspace: file exists

We get this error because either this is not the first gopls instance started by the vscode process and an earlier instance was not shut down normally, or we are reusing a vscode pid and the gopls instance of the previous process was not cleaned up properly. So most likely this is a side-effect of the gopls process having already crashed. This is not a fatal error.

@hyangah
Copy link
Contributor

@hyangah hyangah commented Jan 4, 2021

@findleyr That's what I thought initially. What about the commonDir saw map ... error message in check.go? After that, the connection to server got closed with no further logging.

@samj7792 Was that the first crash log message? Was there any server restart message before the section you shared with us?

@samj7792
Copy link
Author

@samj7792 samj7792 commented Jan 4, 2021

@hyangah I think that was the whole log. I'm new to using Golang, sorry I can't be more help. It seems like sometimes when saving it will delete parts of my code when trying to format things.

@findleyr
Copy link
Contributor

@findleyr findleyr commented Jan 4, 2021

@hyangah commonDir saw map ... is the fatal log message:
https://cs.opensource.google/go/x/tools/+/master:go/packages/golist_overlay.go;l=451;drc=d88ec18c69c70d818214bd2c98f3ce431ea4fd62

I'm not familiar with this code, but looking at the error it appears we're not handling case insensitivity correctly: customFunctions instead of customfunctions in the path to post_login.go. I'm guessing that this is HFS+, which (per my Googling) is case insensitive but case preserving.

I'm afraid this is not the only place where such an assumption is made.

@stamblerre stamblerre transferred this issue from golang/vscode-go Jan 5, 2021
@stamblerre stamblerre changed the title gopls: automated issue report (crash) x/tools/gopls: crash in commonDir with filepath case differences Jan 5, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jan 5, 2021
@stamblerre stamblerre modified the milestones: Unreleased, gopls/vscode-go Jan 7, 2021
@stamblerre stamblerre added this to Needs Triage in vscode-go: gopls by default via automation Jan 7, 2021
@stamblerre stamblerre moved this from Needs Triage to Critical in vscode-go: gopls by default Jan 8, 2021
@heschi
Copy link
Contributor

@heschi heschi commented Jan 8, 2021

It would be hard to put this together with a full trace, but without one I think it's too much for me.

We expect the go command and the editor to send us canonical cased file names. There is one known exception described in #36904 (comment), but we check for that explicitly and anyway it seems unlikely VS Code was opened to the customFunctions directory. I would tend to blame VS Code, but without a trace I can't prove it.

I don't think a fix to go/packages is appropriate, since it's getting bad input. Changing the panic to an error should be an improvement -- if nothing else, saving all the files should avoid the problem, so it's transient by definition. We could do the checkPathCase call more often, but I think I'd rather wait until we have a better understanding of the problem.

I'll change the panic to an error unless someone objects.

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 8, 2021

Change https://golang.org/cl/282732 mentions this issue: go/packages: don't crash if given an invalid overlay

vscode-go: gopls by default automation moved this from To Investigate to Done Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants