Closed mikehaertl closed 2 years ago
Looks like a bug in the prisma parser. Should this issue be upstreamed there ?
Ok, agreed. I'll open another issue there. The issue here can then probably be closed?
let's leave this open for now, we'll need to update the parser once the fix is done.
@kyazdani42 I wondered why the backtrace does not include any pointers to the parser file. I tried to recompile the parser with debug symbols like this:
cc -g -o /home/mike/.local/share/nvim/plugged/nvim-treesitter/parser/prisma.so -I./src src/parser.c -shared -Os -lstdc++
But still there's no trace of prisma's parser in the backtrace.
Do you happen to have some hints how I could further boil this down to the offending line in the parser?
I'm not too sure how to go about that, but i know there is a tool for fuzzying the parser. i know @theHamsta will have more info on this :)
Prisma doesn't use a hand written parser. Bugs in the generated code are very rare but you can try out the fuzzing tool. instructions here https://github.com/ikatyang/tree-sitter-markdown/issues/14
I would try to compile the parser with -O0 instead of -Os
@theHamsta Thanks. I tried the recipe from the comment you linked but it failed at the ./script/build-fuzzer
step:
[mike@Nilar tree-sitter]$ ./script/build-fuzzers
cc -fsanitize=fuzzer,address,undefined -std=gnu99 -fPIC -Ilib/src -Ilib/include -c -o lib/src/tree_cursor.o lib/src/tree_cursor.c
cc: error: unrecognized argument to ‘-fsanitize=’ option: ‘fuzzer’
make: *** [<eingebaut>: lib/src/tree_cursor.o] Fehler 1
I admit that I don't really understand what I'm doing here and how fuzzing works. I couldn't make much sense of the example fuzzer output in your comment either.
I also tried to compile the parser with -o0
but it didn't make any difference in the back trace.
If you have any further hints how to debug this problem maybe you want to comment on the tree-sitter-prisma issue linked above?
@mikehaertl the above script expects CC to be clang (not GCC) to be able to use the memory sanitizer option. Llvm has a library called libfuzzer and clang can use it to construct inputs that cleverly try to run all the code paths of the parser. Clang will need to compile the binary with special flags, also with memory sanitizer which will add additional checks to detect segfaults, usage of uninitialized memory and similar issues.
@theHamsta I see, thanks for the explanation.
The upstream issue meanwhile has been fixed. I don't remeber if the version has to be pushed in this repo or if this happens automatically.
The upstream issue meanwhile has been fixed. I don't remeber if the version has to be pushed in this repo or if this happens automatically.
This happens automatically (well, not fully; I still have to press a few buttons.)
If the fix was not made in the last few minutes, it's now pulled in by nvim-treesitter: https://github.com/nvim-treesitter/nvim-treesitter/commit/7a22d9280119b3e57332ddd855583b609e809ce7
Closing this as the fix seems to work fine.
Describe the bug
When I edit prisma files neovim sometimes crashes with a core dump.
To Reproduce
Expected behavior
No coredump
Output of
:checkhealth nvim-treesitter
Output of
nvim --version
Additional context
I've run
gdb
on the coredump file and got this backtrace: