elm-tooling / tree-sitter-elm

Tree sitter implementation for elm
https://elm-tooling.github.io/tree-sitter-elm/
MIT License
75 stars 15 forks source link

Segfault in neovim when injected in markdown #124

Open kyazdani42 opened 2 years ago

kyazdani42 commented 2 years ago

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

bhansconnect commented 1 year ago

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

kyazdani42 commented 1 year ago

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.

thistent commented 1 year ago

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

bburdette commented 1 year ago

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

razzeee commented 1 year ago

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.

bburdette commented 1 year ago

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

moniquelive commented 1 year ago

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 ()
maca commented 1 year ago

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

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

aaaaargZombies commented 8 months ago

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 commented 7 months ago

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

kyazdani42 commented 7 months ago

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

bburdette commented 7 months ago

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

aaaaargZombies commented 7 months ago

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?

bburdette commented 7 months ago

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.