goplus / goxls

The Go/Go+ Language Server
https://marketplace.visualstudio.com/items?itemName=goplus.gop
Apache License 2.0
2 stars 1 forks source link

panic: runtime error: invalid memory address or nil pointer dereference #7

Open Myzel394 opened 2 months ago

Myzel394 commented 2 months ago

Hey, so I'm trying to get goxls to work on neovim, here's what I did:

Procedure

  1. Install goxls using gop install github.com/goplus/goxls@latest
  2. Start the LSP manually when entering *.gop files:
    -- Custom LSPs
    vim.api.nvim_create_autocmd("BufEnter", {
    pattern = "*.gop",
    callback = function()
        vim.lsp.start({
            name = "goxls",
            cmd = { 
                os.getenv( "HOME" ) .. "/go/bin/goxls",
            },
            root_dir = vim.fn.getcwd(),
        })
    end,
    })
  3. When opening a main.gop files, the following error is thrown:
    [START][2024-08-31 13:42:11] LSP logging initiated
    [ERROR][2024-08-31 13:42:11] .../vim/lsp/rpc.lua:770    "rpc"   "/home/myzel394/go/bin/goxls"   "stderr"    "panic: runtime error: invalid memory address or nil pointer dereference\n[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xdcdcba]\n\ngoroutine 125 [running]:\ngolang.org/x/tools/gopls/internal/lsp/cache.localPackageKey({{0xc0007d79d0, 0x4}, {0xc0007d79d0, 0x4}, {0xc0007d79d4, 0x4}, {0xc0005e4e60, 0x1, 0x1}, {0x1b1c260, ...}, ...})\n\t/home/myzel394/go/pkg/mod/github.com/goplus/tools/gopls@v0.0.0-20240212113720-3c9c8e3d8619/internal/lsp/cache/check.go:1493 +0xcfa\ngolang.org/x/tools/gopls/internal/lsp/cache.(*packageHandleBuilder).buildPackageHandle(0xc000ad31d0, {0x13fb9a8, 0xc0000c8640}, 0xc0000c85f0)\n\t/home/myzel394/go/pkg/mod/github.com/goplus/tools/gopls@v0.0.0-20240212113720-3c9c8e3d8619/internal/lsp/cache/check.go:1143 +0x2e5\ngolang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func2.1()\n\t/home/myzel394/go/pkg/mod/github.com/goplus/tools/gopls@v0.0.0-20240212113720-3c9c8e3d8619/internal/lsp/cache/check.go:942 +0xc8\ngolang.org/x/sync/errgroup.(*Group).Go.func1()\n\t/home/myzel394/go/pkg/mod/golang.org/x/sync@v0.6.0/errgroup/errgroup.go:78 +0x50\ncreated by golang.org/x/sync/errgroup.(*Group).Go in goroutine 123\n\t/home/myzel394/go/pkg/mod/golang.org/x/sync@v0.6.0/errgroup/errgroup.go:75 +0x96\n"

Info

$ nvim --version
NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1713773202
Run "nvim -V1 -v" for more info
$ gop version
gop v1.2.6 linux/amd64
$ go version
go version go1.23.0 linux/amd64
Myzel394 commented 2 months ago

Can confirm this works when using the VS Code extension too:

[Info  - 11:39:56 AM] 2024/09/01 11:39:56 go info for /home/myzel394/CodeProjects/goplus-test
(go dir /home/myzel394/CodeProjects/goplus-test)
(go version go version go1.23.0 linux/amd64)
(valid build configuration = false)
(build flags: [])
(selected go env: [GO111MODULE=, GOCACHE=/home/myzel394/.cache/go-build, GOFLAGS=, GOMODCACHE=/home/myzel394/go/pkg/mod, GOPATH=/home/myzel394/go, GOPRIVATE=, GOROOT=/home/linuxbrew/.linuxbrew/Cellar/go/1.23.0/libexec, GOWORK=])

[Info  - 11:39:56 AM] 2024/09/01 11:39:56 go/packages.Load #1
    snapshot=0
    directory=file:///home/myzel394/CodeProjects/goplus-test
    query=[./ builtin]
    packages=2

[Info  - 11:39:56 AM] 2024/09/01 11:39:56 go/packages.Load #1: updating metadata for 1 packages

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xdcdcba]

goroutine 194 [running]:
golang.org/x/tools/gopls/internal/lsp/cache.localPackageKey({{0xc000426990, 0x28}, {0xc000426990, 0x28}, {0xc000495658, 0x4}, {0xc000566150, 0x1, 0x1}, {0x1b1c260, ...}, ...})
    /home/myzel394/go/pkg/mod/github.com/goplus/tools/gopls@v0.0.0-20240212113720-3c9c8e3d8619/internal/lsp/cache/check.go:1493 +0xcfa
golang.org/x/tools/gopls/internal/lsp/cache.(*packageHandleBuilder).buildPackageHandle(0xc0006cc540, {0x13fb9a8, 0xc0002e2230}, 0xc0002e21e0)
    /home/myzel394/go/pkg/mod/github.com/goplus/tools/gopls@v0.0.0-20240212113720-3c9c8e3d8619/internal/lsp/cache/check.go:1143 +0x2e5
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func2.1()
    /home/myzel394/go/pkg/mod/github.com/goplus/tools/gopls@v0.0.0-20240212113720-3c9c8e3d8619/internal/lsp/cache/check.go:942 +0xc8
golang.org/x/sync/errgroup.(*Group).Go.func1()
    /home/myzel394/go/pkg/mod/golang.org/x/sync@v0.6.0/errgroup/errgroup.go:78 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 180
    /home/myzel394/go/pkg/mod/golang.org/x/sync@v0.6.0/errgroup/errgroup.go:75 +0x96
[Info  - 11:39:56 AM] 
true
[Info  - 11:39:56 AM] 2024/09/01 11:39:56 go info for /home/myzel394/CodeProjects/goplus-test
(go dir /home/myzel394/CodeProjects/goplus-test)
(go version go version go1.23.0 linux/amd64)
(valid build configuration = false)
(build flags: [])
(selected go env: [GO111MODULE=, GOCACHE=/home/myzel394/.cache/go-build, GOFLAGS=, GOMODCACHE=/home/myzel394/go/pkg/mod, GOPATH=/home/myzel394/go, GOPRIVATE=, GOROOT=/home/linuxbrew/.linuxbrew/Cellar/go/1.23.0/libexec, GOWORK=])