Closed marusic1514 closed 3 months ago
Hi there,
My recommendations are:
Put the parsers and languages in global variables instead of initializing parsers and languages at every iteration. Also, use TsParser#reset
to reset the parser state.
Since child.firstByte
and child.lastByte
return offset in raw utf8 bytes, it's better
work with String#getBytes("utf-8")
I have the same issue. Version 0.22.5 is working fine, but when running any never version, the application randomly crashes at some point.
This is from the logs:
# JRE version: OpenJDK Runtime Environment (Red_Hat-21.0.5.0.10-1) (21.0.5+10) (build 21.0.5+10-LTS)
# Java VM: OpenJDK 64-Bit Server VM (Red_Hat-21.0.5.0.10-1) (21.0.5+10-LTS, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C [x86_64-linux-gnu-tree-sitter.so+0x2bf03] ts_subtree_child_count+0x43
Observing core dump errors like this one:
I am using the tree sitter library with multiple different parsers (Kotlin, Java, Typescript, C#, etc) and either can eventually result in the core dump error above.
Do you have a solution?
This is the code, for reference:
where
pickLanguage
picks a parser based on the file extension like so (I use a large variety of parsers and this error seems to happen for any of them):and
chunkRest
does the following (essentially recursively keeps adding children until it runs of Max Chars):