tree-sitter-grammars / tree-sitter-hcl

HCL grammar for tree-sitter
https://tree-sitter-grammars.github.io/tree-sitter-hcl/
Apache License 2.0
91 stars 20 forks source link

Assertion Failed on Terraform Files #46

Closed la0bing closed 2 months ago

la0bing commented 3 months ago

Problem

I am getting the following error when trying to navigate in the nvim editor, on a terraform file, either typing or basic operation throws this and returns me back to the shell: Assertion failed: (length <= TREE_SITTER_SERIALIZATION_BUFFER_SIZE), function ts_parser__external_scanner_serialize, file parser.c, line 404

Reference

https://github.com/tree-sitter/tree-sitter/issues/3406

Steps to reproduce

My configuration is just using the default AstroNVim installation.

git clone --depth 1 https://github.com/AstroNvim/template ~/.config/nvim
rm -rf ~/.config/nvim/.git
nvim

and from here on when i try editing a terraform file it just randomly starts crashing. I've tried using different distros of vim but seems to be still facing the same issue.

Expected behavior

It should not crash.

Tree-sitter version (tree-sitter --version)

tree-sitter 0.22.6

Operating system/version

macOS 14.5

MichaHoffmann commented 3 months ago

Hey,

Thanks for your issue, do you maybe also have an input file where this reproduces on? That would aid debugging alot!

MichaHoffmann commented 3 months ago

I found at least one issue with the size accounting in the serialization function. Are you by chance able to check if it helps? Its hard to tell, i tried reproducing the issue with some prepared heredocs but wasnt able to.

la0bing commented 3 months ago

weirdly after i tried disabling for terraform and re-enabling it i wasnt able to consistantly reproduce it, I have attached a somewhat sanatized version of the file i was facing issue with not sure if this will help. Appreciate the help thanks. file: test.txt

MichaHoffmann commented 3 months ago

weirdly after i tried disabling for terraform and re-enabling it i wasnt able to consistantly reproduce it, I have attached a somewhat sanatized version of the file i was facing issue with not sure if this will help. Appreciate the help thanks. file: test.txt

Wasnt able to reproduce with this file, but let me merge the PR to fix the obvious issue first and Ill keep the issue open.

Edit: cannot merge anymore

MichaHoffmann commented 2 months ago

@la0bing ~ this was closed automatically by merging #47; let me reopen the issue. Can you please check ( once nvim-treesitter updated the revision ) if this fixes your issue?

la0bing commented 2 months ago

@la0bing ~ this was closed automatically by merging #47; let me reopen the issue. Can you please check ( once nvim-treesitter updated the revision ) if this fixes your issue?

thanks for the quick fix on this, not entirely sure if its fixed by this change but I can't seems to reproduce the issue ever since I've disabled and re-enable it, but after updating it I am not facing this issue anymore as well

MichaHoffmann commented 2 months ago

@la0bing Ok, then let me close the issue; if you see it again please feel free to reopen!

xidiot commented 2 months ago

Hey guys, sorry to ask this question, but how can I use the commit (80784600ec08ff2d677362a8a9fd9101c798b49c) in #47 ? I'm using LunarVim and this error is making it to crash? Lazy is the plugin manager used by LunarVim.

MichaHoffmann commented 2 months ago

Are you using nvim-treesitter? In that case it should suffice to just bump its version to latest main. The version of this Parser was bumped there already

xidiot commented 2 months ago

@MichaHoffmann , thank you for the blazing fast response. Yep, I'm using nvim-treesitter. I was update to update to the latest main, but it seems there are some breaking changes, and nvim-treesitter is not able to run at all afterwards :\ . Maybe I'll need to open an issue with LunarVim.

MichaHoffmann commented 2 months ago

I don't know lunar vim but maybe updating the neovim version would help. Are you running recent neovim?

xidiot commented 2 months ago

$ nvim --version NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478

MichaHoffmann commented 2 months ago

Same for me

$ nvim --version
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1693350652
xidiot commented 2 months ago

Yep, that's why I suspect it has something to do with the lunarvim's configuration.