Skip to content

SIGSEGV when accessing a Language #29

@ObserverOfTime

Description

@ObserverOfTime

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?

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions