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
Feature request: add -sanitize
flag to CLI
#3186
Labels
Comments
Yeah I was thinking about adding a |
In the meantime this exists and can also be used locally. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
Modern sanitizers have done a lot to make C/C++ development tolerable. Especially with the requirement to move all external scanners to C, I believe it would be incredibly useful to add a
-sanitize
flag to the tree-sitter CLI which compiles & links all parser/scanner code against every sanitizer under the sun then uses that binary to run the subcommand (most usefullyparse
andtest
). This is certain to unmask various memory leaks and undefined behavior existing in external scanners, as I can tell you from personal experience.Expected behavior
I use sanitizers to test the grammar I develop, which has a fairly complicated external scanner. In lieu something like the proposed
-sanitize
flag I instead created a small C++ shim (adapted from the fuzzer shim) that just loads a single file into the tree-sitter C library (itself also specially compiled with sanitizers) then parses it. You can see the build script & shim here, which requires the tree-sitter repo be present as a git submodule.I believe the
-sanitize
flag would unlock these powerful C/C++ development tools for people who don't want to futz around with compiling & linking things themselves. In particular, it would let people run their own test corpus instead of being restricted to parsing a single file like I am with my simple C++ shim.There are a number of difficulties I foresee when implementing this feature, because I have experienced them myself - but hopefully someone here has a much higher frustration threshold for debugging cross-platform C/C++ linking issues than I do, and can overcome them:
gdb
handles the transition from the CLI into the C/C++ code (never tried).There is a fair amount of risk this feature would generate a lot of "doesn't work on my machine" type bugs but also its value is undeniable, especially if everything is transitioning to C.
The text was updated successfully, but these errors were encountered: