-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Regarding the Arena.ofConfined()
usage: I tested it now in a Linux Docker container and it is crashing there as well with a SIGSEGV. To be safe, could you please try as well?
My code looked like this:
Language language;
try (Arena arena = Arena.ofConfined()) {
SymbolLookup symbols = SymbolLookup.libraryLookup(Path.of("libtree-sitter-java.so"), arena);
language = Language.load(symbols, "tree_sitter_java");
}
try (var parser = new Parser(language)) {
try (var tree = parser.parse(source).get()) {
var rootNode = tree.getRootNode();
}
}
The language pointer is copied into the library arena anyway, so the initial arena shouldn't affect it.
Do you mean this code in the Language
constructor?
java-tree-sitter/src/main/java/io/github/treesitter/jtreesitter/Language.java
Lines 42 to 43 in 364154c
public Language(MemorySegment self) throws IllegalArgumentException { | |
this.self = self.reinterpret(LIBRARY_ARENA, TreeSitter::ts_language_delete); |
The documentation of reinterpret
says (emphasis mine):
Returns a new memory segment with the same address and size as this segment, but with the provided scope.
So maybe this is not actually performing a copy, and therefore after the library was unloaded still refers to that (now unloaded) memory area?
(maybe applies to the other reinterpret
calls in this library as well then)
Originally posted by @Marcono1234 in #24 (comment)