tree-sitter-c icon indicating copy to clipboard operation
tree-sitter-c copied to clipboard

segfault on `time tree-sitter highlight tree-sitter-c/src/parser.c`

Open matu3ba opened this issue 3 years ago • 1 comments

$ RUST_BACKTRACE=1 time tree-sitter highlight tree-sitter-c/src/parser.c

thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 12', cli/src/highlight.rs:359:34
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Command exited with non-zero status 101
0.32user 0.01system 0:00.34elapsed 97%CPU (0avgtext+0avgdata 69464maxresident)k
384inputs+0outputs (4major+16487minor)pagefaults 0swaps

Full backtrack showing alot garbage

$ RUST_BACKTRACE=full time tree-sitter highlight tree-sitter-c/src/parser.c
thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 14', cli/src/highlight.rs:359:34
stack backtrace:
   0:     0x55d02344ba60 - <unknown>
   1:     0x55d0234734cf - <unknown>
   2:     0x55d023444105 - <unknown>
   3:     0x55d02344dceb - <unknown>
   4:     0x55d02344d7bd - <unknown>
   5:     0x55d02344e30d - <unknown>
   6:     0x55d02344de97 - <unknown>
   7:     0x55d02344befc - <unknown>
   8:     0x55d02344ddf9 - <unknown>
   9:     0x55d02314ce01 - <unknown>
  10:     0x55d02314cdc2 - <unknown>
  11:     0x55d0231816b6 - <unknown>
  12:     0x55d02315b47b - <unknown>
  13:     0x55d0231566ec - <unknown>
  14:     0x55d023153813 - <unknown>
  15:     0x55d023153829 - <unknown>
  16:     0x55d02344e70a - <unknown>
  17:     0x55d02315e012 - <unknown>
  18:     0x7f68eb85bb25 - __libc_start_main
  19:     0x55d02314d57e - <unknown>
  20:                0x0 - <unknown>
Command exited with non-zero status 101
0.26user 0.03system 0:00.30elapsed 98%CPU (0avgtext+0avgdata 69708maxresident)k
0inputs+0outputs (0major+16489minor)pagefaults 0swaps

Occured during discussing how to get timings.

Reproducing steps:

cd $HOME
mkdir src; cd src
tree-sitter init-config
git clone https://github.com/tree-sitter/tree-sitter-c
RUST_BACKTRACE=1 time tree-sitter highlight      tree-sitter-c/src/parser.c

rustc 1.56.0 (09c42c458 2021-10-18) gcc (GCC) 11.1.0 clang version 12.0.1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin

$ tree-sitter dump-languages

tree-sitter dump-languages
scope: source.cpp
parser: "/home/misterspoon/src/tree-sitter-cpp/"
highlights: Some(["queries/highlights.scm", "node_modules/tree-sitter-c/queries/highlights.scm"])
file_types: ["cc", "cpp", "hpp", "h"]
content_regex: None
injection_regex: None

scope: source.c
parser: "/home/misterspoon/src/tree-sitter-c/"
highlights: None
file_types: ["c", "h"]
content_regex: None
injection_regex: None

matu3ba avatar Oct 31 '21 13:10 matu3ba

I think the issue is in package.json on tree-sitter-cpp.

The node_modules/tree-sitter-c/queries/highlights.scm should be the path to the highlight query of tree-sitter-c grammar.

alemuller avatar Oct 31 '21 14:10 alemuller

Can't reproduce on master

amaanq avatar Jul 24 '23 08:07 amaanq