tree-sitter / tree-sitter-html

HTML grammar for Tree-sitter
MIT License
136 stars 72 forks source link

SIGSEGV in html highlighting in neovim #102

Closed Blechlawine closed 3 months ago

Blechlawine commented 4 months ago

File where the problem occurs:

<!DOCTYPE html>
<html lang="en">

<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
</head>

<body>

</body>

</html>

lldb output:

(lldb) c
Process 123108 resuming
Process 123108 stopped and restarted: thread 1 received signal: SIGCHLD
Process 123108 stopped and restarted: thread 1 received signal: SIGCHLD
Process 123108 stopped and restarted: thread 1 received signal: SIGCHLD
Process 123108 stopped and restarted: thread 1 received signal: SIGCHLD
Process 123108 stopped and restarted: thread 1 received signal: SIGCHLD
Process 123108 stopped
* thread #1, name = 'nvim', stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
    frame #0: 0x000077e9afea53fe libc.so.6`free + 30
libc.so.6`free:
->  0x77e9afea53fe <+30>: movq   -0x8(%rdi), %rax
    0x77e9afea5402 <+34>: movl   %fs:(%rbx), %ebp
    0x77e9afea5405 <+37>: testb  $0x2, %al
    0x77e9afea5407 <+39>: jne    0x77e9afea5460            ; <+128>
(lldb) bt
* thread #1, name = 'nvim', stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
  * frame #0: 0x000077e9afea53fe libc.so.6`free + 30
    frame #1: 0x000077e9b0277ba9 html.so`tree_sitter_html_external_scanner_destroy + 44
    frame #2: 0x000061929904fccc nvim`ts_parser_reset + 348
    frame #3: 0x0000619299051674 nvim`ts_parser_parse + 3012
    frame #4: 0x0000619298de2e2e nvim`parser_parse + 942
    frame #5: 0x000061929907c216 nvim`lj_BC_FUNCC + 68
    frame #6: 0x0000619299068416 nvim`lua_pcall(L=0x000077e9b013a380, nargs=<unavailable>, nresults=0, errfunc=<unavailable>) at lj_api.c:1151:12
    frame #7: 0x0000619298dd3f3c nvim`nlua_pcall + 108
    frame #8: 0x0000619298ddb960 nvim`ex_lua + 352
    frame #9: 0x0000619298d3ee9d nvim`execute_cmd0 + 205
    frame #10: 0x0000619298d42694 nvim`do_cmdline + 11060
    frame #11: 0x0000619298f852bc nvim`do_ucmd + 2124
    frame #12: 0x0000619298d3eeec nvim`execute_cmd0 + 284
    frame #13: 0x0000619298d42694 nvim`do_cmdline + 11060
    frame #14: 0x0000619298e46255 nvim`nv_colon.lto_priv.0 + 165
    frame #15: 0x0000619298e417ac nvim`normal_execute.lto_priv.0 + 2556
    frame #16: 0x0000619298f226b4 nvim`state_enter + 292
    frame #17: 0x0000619298e4029c nvim`normal_enter + 140
    frame #18: 0x0000619298c0e5d1 nvim`main + 3633
    frame #19: 0x000077e9afe29d90 libc.so.6`___lldb_unnamed_symbol3139 + 128
    frame #20: 0x000077e9afe29e40 libc.so.6`__libc_start_main + 128
    frame #21: 0x0000619298c0ff2e nvim`_start + 46
(lldb)

neovim version: 0.10.0 html-treesitter version: :TSUpdate in neovim says all parsers are up to date os: Linux x86_64 6.5.0-41-generic #41~22.04.2-Ubuntu

I've also observed the same problem with a different fault address (iirc it was 0x0)

amaanq commented 3 months ago

this is because you're using an OLD parser version, ensure you're using the latest one, older versions are not compatible with the latest tree-sitter API.

Blechlawine commented 3 months ago

Well updating doesn't work because it says im already using the latest version... and after reinstalling tree-sitter-html twice it still crashes

gabrieldechichi commented 1 month ago

Had the same problem as @Blechlawine , sharing my solution if anyone else encounters this thread.

In short, @amaanq is right that treesitter version is old, but he didn't specify instructions. In short, you should be using the master branch (stable). The problem ocurred for me because in the past I had locked the version of tree-sitter to 0.9.2, which is fairly old as of today.

TLDR, you want something like this (with no version tag):

return {
    {
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        branch = "master",
    ....
}