Skip to content

ts_parser_parse_string seems to hang when the parsing fails #303

@balsoft

Description

@balsoft

With GHC 9.0.2, ts_parser_parse_string seems to hang if the parsing fails. Reproduce:

❯ ghci
GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help
ghci> import Foreign
ghci> import TreeSitter.Haskell
ghci> import TreeSitter.Parser
ghci> import TreeSitter.Tree
ghci> import Foreign.C
ghci> parser <- ts_parser_new
ghci> _ <- ts_parser_set_language parser tree_sitter_haskell
ghci> (str, len) <- newCStringLen "this hangs everything"
ghci> tree <- ts_parser_parse_string parser nullPtr str len -- This hangs indefinitely
^C^CInterrupted.

The same works if the string is valid tree-sitter's Haskell grammar (including an empty string).

I have tree-sitter-haskell-0.3.0.2, tree-sitter-0.9.0.3 and ghc-9.0.2. If that matters, this is NixOS Linux, and all packages are provided from nixpkgs. The exact environment can be reproduced with NIX_PATH=nixpkgs=https://github.com/nixos/nixpkgs/archive/c5924154f000e6306030300592f4282949b2db6c.tar.gz nix-shell -p 'haskellPackages.ghcWithPackages (ps: with ps; [ tree-sitter tree-sitter-haskell ])' .

I'm not sure how to debug this further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions