-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terminated by signal SIGSEGV (Address boundary error) #72
Comments
Few last lines of
|
Thanks for the report. I think it’s a bug. What language are you parsing? Is the grammar open source? It’d be great to get a reproducible script that causes this. |
I parse php using this grammar
[EDIT] For the record, tree-sitter-node version in use:
|
This snippet currently reproduces the error. Delete last element from "keywords" array and error goes away. const Parser = require('tree-sitter')
const PHP = require('tree-sitter-php')
const parser = new Parser()
parser.setLanguage(PHP)
const tree = parser.parse('<?php //')
const keywords = [
'empty_statement',
'named_label_statement',
'expression_statement',
'if_statement',
'switch_statement',
'while_statement',
'do_statement',
'for_statement',
'foreach_statement',
'goto_statement',
'continue_statement',
'break_statement',
];
const query = keywords.reduce((prev, curr) => {
return prev + `(${curr}) @statement`
}, '');
(new Parser.Query(PHP, query)).matches(tree.rootNode) |
I can't reproduce the problem using this script. What platform are you on? |
Maybe try a bit larger query on your machine, like:
|
Hmm, I still can't reproduce it. I also tried repeating the entire If you get a chance, could you rebuild the To rebuild the module: npm install -g node-gyp
cd node_modules/tree-sitter
node-gyp rebuild --debug Then, to run: lldb node -- test.js Since the trace ends at
|
Thank you for helping me out!
Also, during issue (once you said you cannot reproduce), I updated
|
So we mark this as bug ? |
I have been able to reliably reproduce a seg fault by passing in a single string to a query instead of an S expression, as in I added this to the top of my test: var SegfaultHandler = require('segfault-handler');
SegfaultHandler.registerHandler("crash.log");
|
Also note that I arrived here because of jestjs/jest#8769 (comment) I have a more pernicious seg fault that is ONLY triggered in a Docker environment, which has more limited memory. It's possible that this bug is separate from the one above, and is triggered by an out-of-memory error in Query. |
Reproduce case:
as in new Query(Ruby, ` (assignment
left: (_) @var
right: (method_call
method: (
call receiver: (constant) @class
(#eq? @class "I18n")
method: (identifier) @method
(#eq? @method "namespace")
)
arguments: (
argument_list (
(string) @namespace
)
)
)
)
`) but ONLY in a Docker context, and only inside a jest test. Note that the seg fault occurs in lib_pthread, so this is a threading issue. I am almost certain the NAPI PR will fix this. const Parser = require("tree-sitter");
const Ruby = require("tree-sitter-ruby");
const { Query } = Parser;
describe("createQuery", () => {
it("?", () => {
new Query(Ruby, `
(assignment
left: (_) @var
right: (method_call
method: (
call receiver: (constant) @class
(#eq? @class "I18n")
method: (identifier) @method
(#eq? @method "namespace")
)
arguments: (
argument_list (
(string) @namespace
)
)
)
)
`
);
});
}); |
further context: the lines
are responsible. If I remove either
or
OR remove both predicates (the then the seg fault disappears. |
Thank you @cellog!
What is NAPI PR? |
I wanted to confirm that actually #81 solves this issue for me, and confirm closing this thread, but building the master branch I get this error: make: Entering directory '/home/ada/any-style-new/any-style/node_modules/tree-sitter/build'
make: *** No rule to make target 'Release/obj.target/tree_sitter/vendor/tree-sitter/lib/src/lib.o', needed by 'Release/obj.target/tree_sitter.a'. Stop.
make: Leaving directory '/home/ada/any-style-new/any-style/node_modules/tree-sitter/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/ada/any-style-new/any-style/node_modules/tree-sitter/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (node:events:378:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Linux 5.10.13-arch1-1
gyp ERR! command "/usr/bin/node" "/home/ada/any-style-new/any-style/node_modules/tree-sitter/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /home/ada/any-style-new/any-style/node_modules/tree-sitter
gyp ERR! node -v v15.11.0
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok This time again I am not sure if that is my fault or not. When would the #81 be released? |
FWIW and in case anyone else runs into this, make sure to clone with submodules: git clone --recurse-submodules |
I am no expert in nodejs - this happens to me when running larger queries. Is this a bug or this means I should do some sort special nodejs configuration?
The text was updated successfully, but these errors were encountered: