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: emacs crash when using gopls with Go 1.20 #58236

Closed
jackgris opened this issue Feb 2, 2023 · 5 comments
Closed

x/tools/gopls: emacs crash when using gopls with Go 1.20 #58236

jackgris opened this issue Feb 2, 2023 · 5 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@jackgris
Copy link

jackgris commented Feb 2, 2023

gopls version

golang.org/x/tools/gopls v0.11.0
    golang.org/x/tools/gopls@v0.11.0 h1:/nvKHdTtePQmrv9XN3gIUN9MOdUrKzO/dcqgbG6x8EY=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/exp@v0.0.0-20221031165847-c99f073a8326 h1:QfTh0HpN6hlw6D3vu8DAwC8pBIwikq0AI1evdm+FksE=
    golang.org/x/exp/typeparams@v0.0.0-20221031165847-c99f073a8326 h1:fl8k2zg28yA23264d82M4dp+YlJ3ngDcpuB1bewkQi4=
    golang.org/x/mod@v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
    golang.org/x/sync@v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
    golang.org/x/sys@v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
    golang.org/x/text@v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
    golang.org/x/tools@v0.3.1-0.20221213193459-ca17b2c27ca8 h1:7/HkGkN/2ktghBCSRRgp31wAww4syfsW52tj7yirjWk=
    golang.org/x/vuln@v0.0.0-20221109205719-3af8368ee4fe h1:qptQiQwEpETwDiz85LKtChqif9xhVkAm8Nhxs0xnTww=
    honnef.co/go/tools@v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
    mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
    mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.20

go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jackgris/.cache/go-build"
GOENV="/home/jackgris/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jackgris/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jackgris/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build44411116=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Every time I open a go file my editor crash, no matter the size of the file, or the project where is the file. This started happening when I update go from 1.95 release to 1.20. The only way I found to fix that is still using the 1.95 release of go.

What did you expect to see?

I'm using emacs, with lsp-mode. I expect to see lsp server start and connected to gopls

What did you see instead?

Instead of that, emacs crash and don't say anything even I use debug flag when running my editor

Editor and settings

I using the flavor spacemacs with the go layer

     (go :variables go-backend 'lsp
         go-format-before-save t
         go-use-golangci-lint t)

Logs

Is almost impossible to see what happen in *lsp-log* buffer, emacs crash really fast

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Feb 2, 2023
@gopherbot gopherbot added this to the Unreleased milestone Feb 2, 2023
@findleyr
Copy link
Contributor

findleyr commented Feb 2, 2023

Gopls should never cause emacs to crash. When you downgrade to 1.19, do you reinstall gopls as well?

Can you run gopls as a daemon to try to see if there is a gopls crash?

In a terminal:

gopls -listen=localhost:8091

And then configure your editor to start gopls with -remote=localhost:8091.

This will allow you to see if the gopls daemon crashes.

@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 2, 2023
@findleyr findleyr changed the title x/tools/gopls: my editor crash with go1.20 released x/tools/gopls: emacs crash when using gopls with Go 1.20 Feb 2, 2023
@findleyr
Copy link
Contributor

findleyr commented Feb 2, 2023

Also: you can pass -logfile=/tmp/gopls.log -rpc.trace to have gopls write logs to a file.

@jackgris
Copy link
Author

jackgris commented Feb 2, 2023

Well this's pretty weird to me, but when I run gopls like daemon and see the log a receive only this:

lsprpc.go:104: Session 15: connected
lsprpc.go:482: Session 15: got handshake. Logfile: "", Debug addr: ""

But also that makes emacs don't crash when I use go 1.20

To connect spacemacs to gopls daemon I had to put this on my spacemacs layer config:

     (go :variables go-backend 'lsp :custom (lsp-gopls-server-args)
         go-format-before-save t
         go-use-golangci-lint t)

And edit that variable in the file lsp-go.el to this:

(defcustom lsp-go-gopls-server-args '("-remote=localhost:8091")

So at the end with the flag lsp-gopls-server-args and restoring his value to:

(defcustom lsp-go-gopls-server-args '("-remote=auto")

I can run emacs without any problem, I am not sure if is that right, but at least I can work with that.

Thanks for your time.

@jackgris jackgris closed this as completed Feb 2, 2023
@jackgris
Copy link
Author

jackgris commented Feb 3, 2023

Well, I discovered my problem was with golangci-lint, sorry for this issue.

@jackgris jackgris reopened this Feb 3, 2023
@jackgris jackgris closed this as completed Feb 3, 2023
@findleyr
Copy link
Contributor

findleyr commented Feb 3, 2023

Thank you for following up, that is good to know!

@golang golang locked and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants