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

SIGSEV when using markdown with embedded 'elm' #3745

Closed
allanderek opened this issue Sep 8, 2022 · 7 comments
Closed

SIGSEV when using markdown with embedded 'elm' #3745

allanderek opened this issue Sep 8, 2022 · 7 comments
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug

Comments

@allanderek
Copy link
Contributor

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.

  1. hx test.md # The file doesn't need to exist but you need to be in markdown mode.
  2. 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 (e8730ca)

@allanderek allanderek added the C-bug Category: This is a bug label Sep 8, 2022
@the-mikedavis the-mikedavis added the A-tree-sitter Area: Tree-sitter label Sep 8, 2022
@the-mikedavis
Copy link
Member

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.

@bhansconnect
Copy link

bhansconnect commented Dec 8, 2022

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.

@mpizenberg
Copy link

I can confirm I have the same issue with helix 22.12 when I have an elm code block in a markdown file.

@magopian
Copy link
Contributor

magopian commented Mar 7, 2023

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.

@bburdette
Copy link

just came here to report this. elm lsp also requires frequent restarts for me fwiw.

@TornaxO7
Copy link
Contributor

TornaxO7 commented Dec 2, 2023

I don't get this error anymore with the latest build from master branch.

@pascalkuthe
Copy link
Member

Likely fixed by #7621 or grammar fixes. Please open a new issue if you can reproduce on latest master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

8 participants