Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Crash when editing a .org file #3376

Closed
nogden opened this issue Aug 9, 2022 · 7 comments · Fixed by #3489
Closed

Crash when editing a .org file #3376

nogden opened this issue Aug 9, 2022 · 7 comments · Fixed by #3489
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug upstream

Comments

@nogden
Copy link
Contributor

nogden commented Aug 9, 2022

Summary

Helix crashes consistently when an .org file contains a * followed by a blank line.

I understand that Helix does not support .org files, but I would expect them to be treated as text files.
Note that the problem does now occur when the file extension is changed to .txt.

Reproduction Steps

Two ways to reproduce this, first interactively:

touch test.org
hx test.org

Enter insert mode and insert a single *.
Return to normal mode.
Use "o" to open a new line below the current line.

The editor freezes and, after a short wait, crashes.

Alternatively:

echo "*\n" > test.org
hx test.org

The above results is a crash.

Helix log

2022-08-09T17:03:52.486 helix_view::theme [WARN] Theme: malformed hexcode: grey09
2022-08-09T17:03:52.488 helix_view::theme [WARN] Theme: malformed hexcode: grey08
2022-08-09T17:03:52.488 helix_view::theme [WARN] Theme: malformed hexcode: grey0D

Platform

Linux (Arch)

Terminal Emulator

Alacritty

Helix Version

helix 22.05 (404defb)

@nogden nogden added the C-bug Category: This is a bug label Aug 9, 2022
@AceofSpades5757
Copy link
Contributor

AceofSpades5757 commented Aug 9, 2022

Replicated the issue. When attempting to delete the trailing \r\n, Helix just freezes with no additional logs when using -vvv.

Version: helix 22.05 (404defb)
OS: Windows 10

2022-08-09T18:52:38.511 helix_view::editor [ERROR] Failed to initialize the LSP for `source.org` { LSP not defined }
2022-08-09T18:52:44.307 helix_loader [DEBUG] Located configuration folders: []
2022-08-09T18:52:44.321 helix_view::editor [ERROR] Failed to initialize the LSP for `source.org` { LSP not defined }
2022-08-09T18:52:52.622 helix_term::commands [TRACE] entering insert mode with sel: Selection { ranges: [Range { anchor: 3, head: 5, horiz: Some(0) }], primary_index: 0 }, text: "*\r\n\r\n"

When attempting to open a file using hx -vvv test.org that just has *\r\n, Helix freezes, but does output the following log.

2022-08-09T19:04:00.343 helix_loader [DEBUG] Located configuration folders: []

@the-mikedavis
Copy link
Member

I understand that Helix does not support .org files

Syntax highlighting is supported for Org files. https://docs.helix-editor.com/lang-support.html

This is an upstream issue with tree-sitter-org: it appears to be entering some sort of loop and consuming all CPU and memory. It looks like this bug is present on the latest commit of tree-sitter-org as well (we're on a2c1946 currently).

I suspect the bug lives in the custom scanner implementation.

I'll open an issue upstream.

@the-mikedavis
Copy link
Member

Hmm interesting I can't reproduce this with tree-sitter-cli's parse, test, or highlight commands. This will take some further debugging but for now it doesn't appear to be an upstream issue.

@archseer
Copy link
Member

Can you use rust-lldb to stop execution and fetch a backtrace during the freeze?

@A-Walrus
Copy link
Contributor

Ran a git bisect and found that the issue first appeared in fd644ccfa24b8141c1b8ea32349a0844fe7c884a, which bumped the treesitter version.
Reverting the commit made it work again, so it appears there was a breaking change in the tree-sitter crate...

@the-mikedavis
Copy link
Member

This may be another manifestation of #2997

There must've been some sort of regression with a change in the tree-sitter C API in v0.20.6->v0.20.8 (I have a v0.20.6 CLI)

@the-mikedavis
Copy link
Member

Looks like this has been fixed recently upstream in tree-sitter-org: milisims/tree-sitter-org#34

See also the discussion in tree-sitter/tree-sitter#1783 for details about the change in v0.20.8 that lead to this.

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

Successfully merging a pull request may close this issue.

5 participants