Repository navigation
fix(pipeline): pad parallel source reads for tree-sitter lookahead - #115
Merged
Merged
Conversation
tree-sitter's lexer peeks a few bytes past the last character, so c023931 and 90e85bb over-allocated every source reader by 16 bytes and zeroed the tail. pass_parallel.c has its own read_file, which both commits missed: it still allocated size + 1. Its buffer goes to cbm_extract_file in the extract workers and to the cross-file LSP re-read, so the parallel path, used for any index of more than 50 files with more than one worker, kept the over-read. Pad it the same way as the other readers. Fixes #114 Signed-off-by: ata-sesli <atasesli@protonmail.com>
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.
Summary
Fixes #114. The parallel indexing path now reads source files with the same 16 zeroed spare bytes as every other source reader. tree-sitter's lexer reads a few bytes past the last character, and those bytes now stay inside the buffer.
Problem
c023931 and 90e85bb changed every source reader to allocate
size + 16and zero the tail, because tree-sitter's lexer peeks past the end of the input (ASan reported it as a heap-buffer-overflow).src/pipeline/pass_parallel.chas its ownstatic read_file, which neither commit touched. It still allocatedsize + 1.That buffer is used in two places:
cbm_extract_file, the same tree-sitter parse the padded sequential reader feeds;The parallel path handles every full index of more than 50 files with more than one worker, and incremental runs of more than 50 changed files. So the unpadded reader is the one most real indexing goes through.
Change
read_fileinpass_parallel.cnow does whatpass_calls.c,pass_usages.cand the other readers do:size + CBM_TS_LOOKAHEAD_PAD(16);nreadtosize;The returned length is unchanged, and the buffer is still NUL-terminated right after the data. Callers see no difference.
The reader is still a copy of the others. Merging the copies is tracked in #110 (one pipeline path) and #113 (shared helpers).
Verification
CBM_TEST_TIERS=all, macOS arm64: 6,447 passed, the same count asmain(665f1d5).git diff --checkpasses.