helix
helix copied to clipboard
SIGSEV when using markdown with embedded 'elm'
Summary
Helix crashes when I try to use elm coded embedded in a markdown file, such as:
```elm
length : List a -> Int
length l =
case l of
[] -> 0
_ :: rest -> 1 + length rest
```
I've narrowed it down to having a colon followed by an upper case letter (which comes up a lot in Elm code because colon starts a type signature and concrete type names start with an upper case letter). So if you save the following as test.md or try to type it in, then hx will crash:
```elm a : L
This is true whether or not you have the closing three back-ticks.
Here is exactly what is shown in my terminal when it crashes as I type.
```elm
2 a : fish: 'hx -v test.md' terminated by signal SIGSEGV (Address boundary error)
3 '''
I ran this with -v and looked at the log, but there doesn't seem to be anything useful:
2022-09-08T14:13:57.875 helix_view::clipboard [INFO] Using xclip to interact with the system and selection (primary) clipboard
2022-09-08T14:13:57.888 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
Reproduction Steps
I don't think there is anything special here.
- hx test.md # The file doesn't need to exist but you need to be in markdown mode.
- Insert the code given below
```elm a : L ```
Helix log
~/.cache/helix/helix.log
please provide a copy of `~/.cache/helix/helix.log` here if possible, you may need to redact some of the lines
As I said above I don't think this is useful but:
2022-09-08T14:13:57.875 helix_view::clipboard [INFO] Using xclip to interact with the system and selection (primary) clipboard
2022-09-08T14:13:57.888 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
Platform
Linux
Terminal Emulator
alacritty 0.10.1
Helix Version
helix 22.08.1 (e8730ca5)
The segfault happens upstream in tree-sitter-elm. tree-sitter-elm has a C++ external scanner which is most likely what causes this but I haven't been able to pinpoint where. I also can't reproduce this with a regular Elm file - only with injected Elm.
Following an issue on tree-sitter-elm, it looks like we can copy what nvim treesitter did to at least work around the issue for now. We just have to tell markdown not to inject elm: https://github.com/fetchfern/nvim-treesitter/commit/9df6ac20b5004cb16d416de0b73d334d1991e277
I tested locally and it stops the segfault.
I can confirm I have the same issue with helix 22.12 when I have an elm code block in a markdown file.
I can confirm that this is still the case on the latest checkout of the master branch today. Removing all the elm code blocks from a markdown file allows me to open it again in helix, and as soon as I type ```elm it segfaults.
just came here to report this. elm lsp also requires frequent restarts for me fwiw.
I don't get this error anymore with the latest build from master branch.
Likely fixed by #7621 or grammar fixes. Please open a new issue if you can reproduce on latest master