Skip to content

Sync vendored array.h to the tree-sitter 0.26.4+ template#340

Open
ericmj wants to merge 1 commit into
tree-sitter:masterfrom
ericmj:sync-array-h-template
Open

Sync vendored array.h to the tree-sitter 0.26.4+ template#340
ericmj wants to merge 1 commit into
tree-sitter:masterfrom
ericmj:sync-array-h-template

Conversation

@ericmj

@ericmj ericmj commented Jul 21, 2026

Copy link
Copy Markdown

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 write contents through Array(void) * and the macros read it back through the concrete array type. gcc at -O2 is entitled to assume those don't alias, and on aarch64-linux it miscompiles scanners into a stale contents write 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant