Sync vendored array.h to the tree-sitter 0.26.4+ template#340
Open
ericmj wants to merge 1 commit into
Open
Conversation
The vendored src/tree_sitter/array.h predates tree-sitter CLI 0.26.4 and still carries the strict-aliasing violation fixed in tree-sitter/tree-sitter@ed6e42c: the _array__* helpers write contents through Array(void)* while the macros read it back through the concrete array type. gcc at -O2 on aarch64-linux miscompiles the scanner's array usage into a stale pointer write after realloc, corrupting the heap. Copy the header verbatim from the CLI 0.26.11 template, which is also what regenerating with a current CLI produces. No parser or scanner changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
src/tree_sitter/array.h predates tree-sitter CLI 0.26.4, so it still carries the strict-aliasing violation fixed in tree-sitter/tree-sitter@ed6e42c: the
_array__*helpers writecontentsthroughArray(void) *and the macros read it back through the concrete array type. gcc at-O2is entitled to assume those don't alias, and on aarch64-linux it miscompiles scanners into a stalecontentswrite after realloc, corrupting the glibc heap. tree-sitter/tree-sitter-haskell#144 is this exact failure in another grammar (fix pending in tree-sitter/tree-sitter-haskell#157); we hit it in production on hex.pm, and this grammar's scanner compiles the same pattern.This copies the header verbatim from the current CLI template (0.26.11), which is also what regenerating with a current CLI produces. No parser or scanner changes; the header is only used by the external scanner.