-
Notifications
You must be signed in to change notification settings - Fork 39
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
Segmentation Fault and crashed neovim #29
Comments
+1, I can replicate when attempting to type at the bottom of the file. |
Related open issue in neovim nvim-treesitter/nvim-treesitter#2972 Workaround
to |
The issue is in |
I made a quick fork where I changed the version (feel free to use it until it's fixed) https://github.com/RobertBrunhage/nvim-treesitter |
Just creating an empty dart file and adding one non-white-space character without a trailing semicolon is enough to cause the segmentation fault. If we write the semicolon first and then insert anything before it the parser won't crash. As simple as this:
|
Same issue here: Reverting to the older revision works :) |
@UserNobody14 I've played around a bit with the scanner and the only way so far I have been able to prevent a segfault without a semi colon at the end is by changing the last |
Hey! I don't have idea of why, but it worked for me as well! |
Let me try adding that fix and running the grammar on a large list of files again, as far as I know it shouldn't cause a big issue. If it works, I'll merge it |
Hmmm. After looking into the problem I can't seem to either replicate it or get the solution you posted to work with our tests. I don't have neovim setup with dart, so I tried running all of the tests I traditionally use, like parsing files and such. Sadly I was not able to recreate any of these issues, which I believe indicates it only happens on reruns of the grammer. Unfortunately without an easy way to replicate it I just don't know what I should do. Near as I can tell the "lookahead == '\0'" line causes it to return true while the string has not yet ended, but this causes nearly all of our tests to fail, and on other projects' scanner.c files, the return false line is still present, so I don't see why it should be causing such an issue. I found that this configuration below successfully runs the tests, but without an easy way to see if it segfaults, i have no way of knowing if it actually fixes the problem. Does anyone have some easy steps for reproducing the issue?
|
You don't need a Neovim setup. Just let the tree-sitter parser run. Instructions ikatyang/tree-sitter-markdown#14 (CC needs to be clang and python in the script python2). I've provided sample inputs that let the parser crash in the original issue, but I would recommend running the fuzzer (maybe even on CI) |
If this is really a bug in tree-sitter, you could have a look at our open issue with tree-sitter-prisma which crashes without a custom parser @Kavantix . There is even a closed issue for tree-sitter-pug which hd the same issue that could be fixed by a check for |
@theHamsta could you link the issues you mentioned? @UserNobody14 I reproduced it by running tree-sitter highlight on a file containing a few random characters and no semicolon at the end. E.g. |
@Kavantix here you go: nvim-treesitter/nvim-treesitter#2972 (comment) As you say, no need to use vim. I bisected using I should really open a PR to document how to setup fuzzing in upstream tree-sitter. We found quite a lot parser issue with tree-sitter's fuzzing setup. |
Is the current workaround is the one offered by @genesistms , to revert to SHA f95876f of this repo? This is a manual step so all new users of Neovim + TS + Dart will have to perform it on their own. nvim-treesitter/nvim-treesitter#2972 which was referenced earlier as the matching TS issue is now marked as closed. |
Coming to this from nvim-treesitter. Adding the following to
This should at least help debugging the test. The reason of the segfault is still a mistery to me, and the |
Changing the scanner to always return false immediately gives the same crash, so it is not because of the scanner |
Now that's interesting... |
Any chance to revert back to the working commit until the problem is solved? |
nvim-treesitter now uses an older working version for now: nvim-treesitter/nvim-treesitter@d99b4cd |
@theHamsta a fuzzing setup guide would be tremendously appreciated, I'd love to fuzz my grammar. |
@ahelwer Can't count how often I linked this post ikatyang/tree-sitter-markdown#14 (comment) |
@theHamsta maybe we could host a wiki page for this, although the comment is good, debugging the error is a bit more complicated than just running the fuzzer :) |
Ideally such a documentation is contributed to tree-sitter upstream. On how to create safe, fuzzed parsers. |
I guess so. I will look at this next week |
Alright I got a commit working with @Kavantix 's highlight dhdh file as well as @vigoux 's "weird file" test (thanks btw!). Unfortunately it's still hard for me to be sure it won't crash again. Let me know if it keeps happening with the latest changes. I'm not a genius user of scanner.c, sadly, I just kinda copied and pasted from various other tree sitter repos until I got it working. If anyone knowledgeable of C and tree-sitter wants to take a crack at it, I'd be happy to assist/merge your commits. |
Seems to be ok now. Fuzzed for 55mins. Can the others please confirm that this is gone now also in Neovim? |
I can confirm that this issue has been fixed on neovim, although it seems that the speed for the first load is back to normal |
also, the flutter project does not crash now for me |
For me the crash still happens on 53485a8 |
yeap still happening :( |
Can anyone provide a test or a specific file that crashes? I've tested it with empty files and files with a single variable but no dice. |
This is for querying (it uses the highlight queries in this project repo). Let me check whether it also crashes for parsing.
@maxbrunsfeld do you have an idea why the fuzzer could be crashing when querying but not on parsing? |
It does not seem to crash when just using the fuzzer to parse. Just when the fuzzer script also tries to query using |
If you can find a minimal query and source file that reproduces the error (via the |
It just happened to me |
I'm assuming people are still seeing this. I am working on updating this library for newer dart syntax, and have been trying to clean up the grammar slightly as I go. However, it seems like the issue stems not from the grammar but rather from the highlights file. The highlights currently only have a few test cases. I'll see what I can do to get a more comprehensive testing setup there, which will help diagnose this issue. In the meantime if someone wants to try the latest commits in this repo and determine whether the issue is no longer present that would be great. (I do not personally use NeoVim or the highlights currently). Additionally anyone who would like to contribute to the test cases for highlighting I'd be happy to review PRs. CC @theHamsta |
@TimWhiting Can confirm, I am using the latest commit and still experiencing crashes when using with neovim and dartls. |
Crashing neovim completely, Segmentation Fault (Core dumped).
The text was updated successfully, but these errors were encountered: