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

illegal hardware instruction when opening SQL file #5071

Closed
tkellogg opened this issue Dec 8, 2022 · 2 comments · Fixed by #5683
Closed

illegal hardware instruction when opening SQL file #5071

tkellogg opened this issue Dec 8, 2022 · 2 comments · Fixed by #5683
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug upstream

Comments

@tkellogg
Copy link

tkellogg commented Dec 8, 2022

Summary

I tried to open a 13MB file and helix crashed

file: https://gist.github.com/tkellogg/bbf57f5c43489a1e122b4f1a8d0daa9b

to create the file, I did a docker exec ... >tmp.sql. Not sure if that creates unexpected characters.

Helix was installed and then (today) updated via homebrew.

➜  ~ brew info helix
==> helix: stable 22.12 (bottled), HEAD
Post-modern modal text editor
https://helix-editor.com
/usr/local/Cellar/helix/22.12 (801 files, 121MB) *
  Poured from bottle on 2022-12-08 at 12:09:17
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/helix.rb
License: MPL-2.0
==> Dependencies
Build: rust ✘
==> Options
--HEAD
	Install HEAD version
==> Caveats
zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Analytics
install: 4,562 (30 days), 14,306 (90 days), 18,920 (365 days)
install-on-request: 4,578 (30 days), 14,324 (90 days), 18,937 (365 days)
build-error: 1 (30 days)

Reproduction Steps

I tried this:

  1. hx tmp.sql

Here's a link to the file: https://gist.github.com/tkellogg/bbf57f5c43489a1e122b4f1a8d0daa9b

I expected this to happen:
The file opens

Instead, this happened:
Helix hangs for ~60 seconds and then crashes with an error:

[1]    98496 illegal hardware instruction  hx tmp.sql

Helix log

~/.cache/helix/helix.log

Nothing seems relevant here

2022-11-07T11:12:13.459 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
2022-11-07T11:12:53.358 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
2022-11-07T17:00:47.548 helix_view::editor [ERROR] Failed to initialize the LSP for `source.bash` { cannot find binary path }
2022-11-10T15:39:11.363 helix_view::editor [ERROR] Failed to initialize the LSP for `source.python` { cannot find binary path }
2022-11-10T15:43:06.944 helix_view::editor [ERROR] Failed to initialize the LSP for `source.python` { cannot find binary path }
2022-11-10T15:47:09.482 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
2022-11-22T09:03:45.806 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
2022-11-22T09:04:14.649 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
2022-11-22T10:44:36.778 helix_view::editor [ERROR] Failed to initialize the LSP for `text.html.basic` { cannot find binary path }
2022-11-22T10:49:06.976 helix_view::editor [ERROR] Failed to initialize the LSP for `source.css` { cannot find binary path }
2022-11-22T10:50:58.988 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
2022-11-22T11:07:56.772 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
2022-11-22T11:08:46.096 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
2022-11-22T11:11:18.749 helix_view::editor [ERROR] Failed to initialize the LSP for `source.md` { LSP not defined }
2022-11-29T09:35:59.811 helix_view::editor [ERROR] Failed to initialize the LSP for `source.json` { cannot find binary path }
2022-11-29T09:45:20.084 helix_view::editor [ERROR] Failed to initialize the LSP for `source.json` { cannot find binary path }
2022-11-29T09:50:52.831 helix_view::editor [ERROR] Failed to initialize the LSP for `source.json` { cannot find binary path }
2022-11-29T09:51:43.498 helix_view::editor [ERROR] Failed to initialize the LSP for `source.json` { cannot find binary path }

Platform

macOS 13.0.1

Terminal Emulator

iTerm2 3.4.18

Helix Version

helix 22.12 (96ff64a)

@tkellogg tkellogg added the C-bug Category: This is a bug label Dec 8, 2022
@pascalkuthe
Copy link
Member

Thanks for adding a reproduciable example that was really helpful!

I think the illegal hardware instruction is just throwing us off here. This seems to be an issue in the treesitter grammar. On my machine (linux - amd64) it crashes with a free() of wrong size sigfault.
Bumping the treesitter grammar to the newest versions seems to fix the crash. However typing still was dreadfully slow so I suspect the parser.

We should look into this further if there is any issue on the helix side or if it's just an upstream problem and bumping the grammar is enough here.

For now you can update the grammar by adding

[[language]]
name = "sql"
[[grammar]]
name = "sql"
source = { git = "https://github.com/DerekStride/tree-sitter-sql", rev = "a4dd131eeb9fe7f3c9c2ca0f506f6d58d9986a97" }

to your languages.toml and running hx -g fetch and hx -g build to rebuild the grammar.
This should allow you to atleast open and navigate the file. If you want to edit it I would suggest setting :langauge text to disable treesitter for this file once it's opened

@LeoniePhiline
Copy link
Contributor

LeoniePhiline commented Jan 28, 2023

The bad performance could also come from a greedily-matching /.*\n/. I assume this runs through the entire document constantly.

I proposed a change to /.*?\n/ but failed to verify the fix.

(Couldn't get my changes to grammar.js to apply, despite deleting sql.so and re-creating it with hx -g build. (Also made sure $HELIX_RUNTIME is correct.)

DerekStride/tree-sitter-sql#72

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.

4 participants