bonede / tree-sitter-ng

Next generation Tree Sitter Java binding.
MIT License
72 stars 10 forks source link

TreeSitterSql randomly produces null pointers #32

Closed valepakh closed 4 months ago

valepakh commented 4 months ago

This test sometimes fails:

@RepeatedTest(1000)
void nodeType() {
    TSParser parser = new TSParser();
    parser.setLanguage(new TreeSitterSql());
    TSTree tree = parser.parseString(null, "c");
    TSTreeCursor cursor = new TSTreeCursor(tree.getRootNode());
    TSNode node = cursor.currentNode();
    assertThat(node.getType(), is(notNullValue()));
}

It's unclear whether this method can return null or not but it seems to be dependent on the moon phase or something. First repetition seems to reliably fail, then about 200 repetitions pass, then a dozen or so fail. Most probably it's a tree-sitter-sql issue, but it's hard to tell without building the native code and debugging it.

bonede commented 4 months ago

v0.22.6a has fixed a few memory related issues, please upgrade to this version and try again.

valepakh commented 4 months ago

v0.22.6a has fixed a few memory related issues, please upgrade to this version and try again.

Yes, now it looks like it always return non-null value.