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

hx freezes with 100% CPU use editing a specific Elm file #2997

Closed
jhbrown-veradept opened this issue Jul 7, 2022 · 6 comments · Fixed by #3497
Closed

hx freezes with 100% CPU use editing a specific Elm file #2997

jhbrown-veradept opened this issue Jul 7, 2022 · 6 comments · Fixed by #3497
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug upstream

Comments

@jhbrown-veradept
Copy link

Summary

Problem: hx freezes with 100% CPU use when I try to edit a specific Elm file. I have to kill the process manually.

Reproduction Steps

  1. Save the Elm code below to a file named Bogus.elm.
  2. Invoke hx Bogus.elm
  3. Press i to enter insert mode
  4. Type a few characters. hx will freeze.

(I have reduced the original file to this self-contained demo file. Reducing the file complexity further seems to make the freezing problem go away.)

module Bogus exposing (..)

import NotRealThing as El


type alias Model =
    { state : State
    }


type State
    = State (Result Err Data)


view shared model =
    case model.state of
        State outcome ->
            case outcome of
                Ok _ ->
                    [ El.text "Success!" ]

                Err (SubErr SubErrType) ->
                    [ El.text "Specific failure already in use" ]

                Err e ->
                    [ El.text "general failure" ]

Helix log

Log from running with -vvv attached
helix.log

Platform

MacOS 12.4 (21F79) Mac M1 Arm

Terminal Emulator

iterm2 3.4.16, and Mac Terminal 2.12.7 (445)

Helix Version

22.05-218-gb6122110

@jhbrown-veradept jhbrown-veradept added the C-bug Category: This is a bug label Jul 7, 2022
@jhbrown-veradept
Copy link
Author

elm-language-server version info:

 npm ls -g
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
/Users/jhbrown/.nvm/versions/node/v16.15.1/lib
├── @elm-tooling/[email protected]
├── [email protected]
└── [email protected]

@SiriusStarr
Copy link
Contributor

Cannot replicate this with helix 22.05 (27609f50), can replicate with master; currently git bisecting, but my computer builds very slowly... 😆

@SiriusStarr
Copy link
Contributor

SiriusStarr commented Jul 7, 2022

Okay, bisect done, this was introduced by bumping tree-sitter in fd644cc So maybe an infinite loop in https://github.com/elm-tooling/tree-sitter-elm that showed up with the new tree-sitter version?

@SiriusStarr
Copy link
Contributor

Building with

[[package]]
name = "tree-sitter"
version = "0.20.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "549a9faf45679ad50b7f603253635598cf5e007d8ceb806a23f95355938f76a0"

solves the problem, so it was introduced in v0.20.8.

@kirawi kirawi added the upstream label Jul 7, 2022
@SiriusStarr
Copy link
Contributor

Poking around upstream, another bisect shows that tree-sitter/tree-sitter@d223a81 (between v0.20.7 and v0.20.8) breaks 3 tests in https://github.com/elm-tooling/tree-sitter-elm so it's possible that that is the offending commit, though I haven't been able to find any sort of infinite loop or anything playing around with tree-sitter outside of helix.

@archseer
Copy link
Member

archseer commented Jul 7, 2022

I'd recommend also opening an issue upstream and link to this tracking issue.

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 upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants