Giter VIP home page Giter VIP logo

Comments (13)

clason avatar clason commented on June 21, 2024 1

You can check the code to see exactly how we build it. This needs to be fixed upstream; if you rely on the parser, just lock your nvim-treesitter version until then.

from nvim-treesitter.

clason avatar clason commented on June 21, 2024 1

I think they are functionally equivalent. You can test tree-sitter build -o php_only.so to see how that behaves. (Nvim-treesitter will switch to that in 1.0 anyway.)

from nvim-treesitter.

liljaylj avatar liljaylj commented on June 21, 2024 1

@clason reported upstream.

I don't know if it will help, I found that error occurs on injections (and when compiled with -Os of course).

reproducer:

<?php

$query = <<<SQL
select * from users;
SQL;

from nvim-treesitter.

clason avatar clason commented on June 21, 2024

Then you should report that with that parser; there's nothing we can do about it here.

from nvim-treesitter.

przepompownia avatar przepompownia commented on June 21, 2024

Not completely. Maybe it would be better to revert 4e21361 while the parser crashes on tree-sitter/tree-sitter-php@58054be.

On the tree-sitter-php side I still haven't investigated how to get the same parser binary as created with nvim-treesitter. It differs from the build by make -C php_only there. That's (at least) why I can't report a bug there for now.

from nvim-treesitter.

przepompownia avatar przepompownia commented on June 21, 2024

Yet one note here (on Linux with gcc).

  1. nvim-treesitter builds the parser with
cc -o parser.so -I./src src/parser.c src/scanner.c -Os -shared -fPIC`
  1. make's output on the project shows another way of building the binary that doesn't crash:
    cc -Isrc -std=c11 -fPIC   -c -o src/parser.o src/parser.c
    cc -Isrc -std=c11 -fPIC   -c -o src/scanner.o src/scanner.c
    ar rv libtree-sitter-php_only.a src/parser.o src/scanner.o
    ar: creating libtree-sitter-php_only.a
    a - src/parser.o
    a - src/scanner.o
    cc  -shared -Wl,-soname,libtree-sitter-php_only.so.0 src/parser.o src/scanner.o  -o libtree-sitter-php_only.so
  1. The CLI seems to build its own parser binary (stored in ~/.cache folder) in an unknown way, which makes reproduction difficult (tree-sitter/tree-sitter#3336).

Should we assume that the way used by nvim-treesitter is always correct?

from nvim-treesitter.

przepompownia avatar przepompownia commented on June 21, 2024

I think they are functionally equivalent.

For some reason, 1. produces crashing binary unlike 2.

tree-sitter build -o php_only.so

I'm confused: currently I have CLI written in Rust, from Debian package (0.20.8-5). It does not have build subcommand. I tried tree-sitter generate --build. It resulted with ~/.cache/tree-sitter/lib/php_only.so but without details about compiling.

from nvim-treesitter.

clason avatar clason commented on June 21, 2024

Yeah, that's too old. Current is 0.22.5 (soon to be 6), with massive changes. That's what we target, exclusively.

from nvim-treesitter.

przepompownia avatar przepompownia commented on June 21, 2024

Indeed, in the new version build exists and builds the correct binary.

from nvim-treesitter.

liljaylj avatar liljaylj commented on June 21, 2024

I faced simlar issue. when trying to open some php files I get munmap_chunk(): invalid pointer. after bisecting and looking at tree-sitter-php's makefile and nvim-treesitter's source code, I found out that if we don't include compiler flag -Os (optimize for size), then error would not occur.

from nvim-treesitter.

clason avatar clason commented on June 21, 2024

Please report that upstream; a valid compiler flag should not lead to a segfault. (Also, try a newer gcc, or clang.)

from nvim-treesitter.

amaanq avatar amaanq commented on June 21, 2024

Fixed in tree-sitter/tree-sitter-php@27afeb0

from nvim-treesitter.

przepompownia avatar przepompownia commented on June 21, 2024

Thank you all for your involvement. After fixing the parser built by nvim-treesitter works for me as expected.

from nvim-treesitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.