tree-sitter-elm icon indicating copy to clipboard operation
tree-sitter-elm copied to clipboard

Segfault in neovim when injected in markdown

Open kyazdani42 opened this issue 2 years ago • 14 comments

Hi, when injecting an elm tag inside markdown in neovim, neovim will segfault. To reproduce:

  • open nvim test.md (with nvim-treesitter and elm/markdown parsers installed)
  • write:
```elm
`

I first thought it was related to the markdown parser, but since other languages do not segfault, i believe this is related to this parser.

kyazdani42 avatar Jul 02 '22 10:07 kyazdani42

This unsurprisingly is also reproducible in other editors. I just hit it in helix. Someone else also hit it an filed a while back: https://github.com/helix-editor/helix/issues/3745

bhansconnect avatar Dec 08 '22 04:12 bhansconnect

Update: this bug doesn't seem to happen anymore. However, it seems writing any elm code in a fenced markdown code block leads to the editor crashing.

kyazdani42 avatar Jan 21 '23 12:01 kyazdani42

I just encountered a similar problem in helix with a normal Elm module (with an invalid use of an undefined type instance as the input to a case expression): https://github.com/helix-editor/helix/issues/6981

thistent avatar May 06 '23 21:05 thistent

reproduced this in helix with dillonkearns/elm-markdown. cd to repo, space-f, segfault. helix 23.03, elm-language-server 2.7.0.

bburdette avatar May 08 '23 13:05 bburdette

I'm not able to reproduce it, entering the mentioned code in test.elm and running npm run parse-test. I've tried with all inbetween states I could think of.

razzeee avatar May 10 '23 21:05 razzeee

maybe the problem isn't in the parsing but something that happens after that? just guessing

bburdette avatar May 11 '23 22:05 bburdette

If it helps, here's a fresh stack trace taken today:

(gdb) bt
#0  0x0000555555951d24 in ts_decode_utf8 ()
#1  0x0000555555951f27 in ts_lexer.get_lookahead ()
#2  0x00005555559522b2 in ts_lexer.get_column ()
#3  0x00007ffff57302bb in tree_sitter_elm_external_scanner_scan () from /home/cyber/.local/share/nvim/lazy/nvim-treesitter/parser/elm.so
#4  0x000055555593f03a in ts_parser_parse ()
#5  0x000055555574f67e in parser_parse.lto_priv ()
#6  0x00005555559773f6 in lj_BC_FUNCC ()
#7  0x00005555559637f6 in lua_pcall (L=0x7ffff7e65380, nargs=<optimized out>, nresults=1, errfunc=<optimized out>) at lj_api.c:1116
#8  0x000055555573ed08 in nlua_pcall ()
#9  0x0000555555744640 in nlua_call_ref ()
#10 0x0000555555631937 in getnextac ()
#11 0x00005555556daecc in do_cmdline ()
#12 0x0000555555630b38 in apply_autocmds_group ()
#13 0x00005555557c8cc0 in did_set_string_option ()
#14 0x00005555557cb61f in set_string_option ()
#15 0x00005555556e3e73 in ex_setfiletype.lto_priv ()
#16 0x00005555556d7d8d in execute_cmd0 ()
#17 0x00005555556d83e4 in execute_cmd ()
#18 0x0000555555604e0b in nvim_cmd ()
#19 0x00005555555e8fba in nlua_api_nvim_cmd.lto_priv ()
#20 0x00005555559773f6 in lj_BC_FUNCC ()
#21 0x00005555559637f6 in lua_pcall (L=0x7ffff7e65380, nargs=<optimized out>, nresults=1, errfunc=<optimized out>) at lj_api.c:1116
#22 0x000055555573ed08 in nlua_pcall ()
#23 0x0000555555744640 in nlua_call_ref ()
#24 0x00005555555ffe7f in nvim_buf_call ()
#25 0x00005555555e886b in nlua_api_nvim_buf_call.lto_priv ()
#26 0x00005555559773f6 in lj_BC_FUNCC ()
#27 0x00005555559637f6 in lua_pcall (L=0x7ffff7e65380, nargs=<optimized out>, nresults=1, errfunc=<optimized out>) at lj_api.c:1116
#28 0x000055555573ed08 in nlua_pcall ()
#29 0x0000555555744640 in nlua_call_ref ()
#30 0x0000555555631937 in getnextac ()
#31 0x00005555556daecc in do_cmdline ()
#32 0x0000555555630b38 in apply_autocmds_group ()
#33 0x00005555556faad6 in readfile ()
#34 0x00005555556383fb in open_buffer ()
#35 0x00005555555e26fd in main ()

moniquelive avatar Aug 03 '23 19:08 moniquelive

had the same issue in helix with dillonkearns/elm-markdown

https://github.com/helix-editor/helix/issues/6981

maca avatar Sep 20 '23 23:09 maca

Just discovered the same issue in neovim with codeblocks and elm in markdown, I was going to post an issue but instead I guess I'll just follow this thread.

In the mean time I'm currently trying to figure out if I can disable specific parsers on a per file type basis, will report back if if this works as a temporary fix.

aaaaargZombies avatar Mar 03 '24 13:03 aaaaargZombies

For anyone else who is having the same issue, I updated nvim to v0.9.5 and the issue is no longer effecting me.

aaaaargZombies avatar Mar 25 '24 21:03 aaaaargZombies

I don't see this issue too anymore, should we close it ?

kyazdani42 avatar Mar 26 '24 21:03 kyazdani42

I'm still seeing this crash in elm-language-server 2.8.0, with the helix editor.

bburdette avatar Mar 27 '24 13:03 bburdette

I'm still seeing this crash in elm-language-server 2.8.0, with the helix editor.

looks like helix is behind this repo https://github.com/helix-editor/helix/blob/master/languages.toml#L1674 might be an easy PR to make if that fixes it?

aaaaargZombies avatar Mar 27 '24 17:03 aaaaargZombies

I put this

[[grammar]]
name = "elm"
source = { git = "https://github.com/elm-tooling/tree-sitter-elm" , rev = "09dbf221d7491dc8d8839616b27c21b9c025c457" }

Into my .config/helix/langauges.toml file, but it still crashes. rev is current main since feb 18.

No idea if I'm doing it right, but gave it a shot.

bburdette avatar Mar 27 '24 19:03 bburdette