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

Neovim 0.10.1 crashes when editing a Kotlin file and Treesitter ist activated #135

Closed
cmon1701 opened this issue Aug 1, 2024 · 7 comments

Comments

@cmon1701
Copy link

cmon1701 commented Aug 1, 2024

When I edit a simple Kotlin file (the one that is generated via gradle init) and Treesitter is active, Neovim frequently crashes.
After :TSUninstall kotlin, Neovim does not crash, so it is a Treesitter kotlin issue.

This solution did not help: #57
After TSInstall kotlin, Neovim crashes again.

@Akeboshiwind
Copy link

I'm getting this same crash, to help with reproduction here's a minimal config:

minimal.lua
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
  vim.fn.system {
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  }
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function () 
      local configs = require("nvim-treesitter.configs")

      configs.setup({
          ensure_installed = { "kotlin" },
          sync_install = false,
          highlight = { enable = true },
        })
    end
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

And here's my steps to reproduce:

  1. nvim -nu minimal.lua test.kt
  2. If first time then wait for plugins to be installed then :q out of the lazy.nvim menu
  3. Type "test"

I find that nvim crashes when you type the e

nvim -v
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1720049189

And running on an M2 MacBook Air

Hope this helps :)

@cmon1701
Copy link
Author

cmon1701 commented Aug 1, 2024

Thank you, @Akeboshiwind! Now I have a sensible minimal.lua for a lot of things :-)
Your minimal.lua also causes crashes on my computer.
For me, a lot of letters cause the crash.

@LnxFCA
Copy link

LnxFCA commented Aug 1, 2024

Same here, I'm using the markdown and markdown-inline parsers. Typing the e letter within a string crashes Neovim with the following errors:

Process 16085 (nvim) of user 1000 dumped core.
                                                      
                                                      Stack trace of thread 16085:
                                                      #0  0x000071c88d61e5b0 n/a (/home/xxxx/.local/share/nvim/lazy/nvim-treesitter/parser/kotlin.so + 0x1e5b0)
                                                      #1  0x000071c88e8613ee ts_parser_parse (libtree-sitter.so.0 + 0xe3ee)
                                                      #2  0x000065435d1d8cc5 n/a (nvim + 0x243cc5)
                                                      #3  0x000071c88e7b8ef6 n/a (libluajit-5.1.so.2 + 0x6ef6)
                                                      #4  0x000071c88e7ccbea lua_pcall (libluajit-5.1.so.2 + 0x1abea)
                                                      #5  0x000065435d3ff9ee n/a (nvim + 0x46a9ee)
                                                      #6  0x000065435d4099d1 n/a (nvim + 0x4749d1)
                                                      #7  0x000065435d06ebcb decor_providers_invoke_win (nvim + 0xd9bcb)
                                                      #8  0x000065435d08ff72 n/a (nvim + 0xfaf72)
                                                      #9  0x000065435d08b9f6 update_screen (nvim + 0xf69f6)
                                                      #10 0x000065435d09ff7d n/a (nvim + 0x10af7d)
                                                      #11 0x000065435d095c6e n/a (nvim + 0x100c6e)
                                                      #12 0x000065435d342c33 state_enter (nvim + 0x3adc33)
                                                      #13 0x000065435d3fa155 n/a (nvim + 0x465155)
                                                      #14 0x000065435d2543f0 n/a (nvim + 0x2bf3f0)
                                                      #15 0x000065435d248b67 n/a (nvim + 0x2b3b67)
                                                      #16 0x000065435d342d2d state_enter (nvim + 0x3add2d)
                                                      #17 0x000065435d245d2a normal_enter (nvim + 0x2b0d2a)
                                                      #18 0x000065435cfdfb27 main (nvim + 0x4ab27)
                                                      #19 0x000071c88e495e08 n/a (libc.so.6 + 0x25e08)
                                                      #20 0x000071c88e495ecc __libc_start_main (libc.so.6 + 0x25ecc)
                                                      #21 0x000065435cfe1655 _start (nvim + 0x4c655)
                                                      
                                                      Stack trace of thread 16087:
                                                      #0  0x0000000000000000 n/a (n/a + 0x0)
                                                      ELF object binary architecture: AMD x86-64

Here is the markdown codeblock:

fun main() {
    println("He")
}

@Akeboshiwind
Copy link

@cmon1701 I can't take credit, it's from the telescope repo :)

Also to be clear it's not just the letter e, but the second letter typed.

You can do the following:

  1. echo '"t' > test.kt
  2. nvim -nu minimal.lua test.kt
  3. Enter any character at the end of the partially created string

Interestingly you can keep entering things at the beginning of the string 🤷

@fwcd
Copy link
Owner

fwcd commented Aug 3, 2024

#136 fixes a crash in the scanner, mind checking if 0.3.8 fixes it?

@Akeboshiwind
Copy link

I can confirm that this fixes it for me 👍

@cmon1701
Copy link
Author

cmon1701 commented Aug 5, 2024

I can confirm this, too. Thank you!
I wonder why nobody else noticed that before, is Kotlin used so rarely?

@cmon1701 cmon1701 closed this as completed Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants