Skip to content

Reset result_symbol field of lexer in wasm memory in between invocations#4218

Merged
maxbrunsfeld merged 1 commit intomasterfrom
initialize-wasm-lexer-completely
Feb 18, 2025
Merged

Reset result_symbol field of lexer in wasm memory in between invocations#4218
maxbrunsfeld merged 1 commit intomasterfrom
initialize-wasm-lexer-completely

Conversation

@maxbrunsfeld
Copy link
Contributor

Background

Normally, the external scanners are expected to assign to the result_symbol field of the TSLexer before returning true. But if they don't assign it, it is initialized with a default value of zero (the first external token, whatever that is).

Currently, the tree-sitter-yaml external scanner (and possibly others) rely on this zero value, and sometimes return true without writing to it.

Problem

When running external scanners loaded from WASM, we did not reset result_symbol in between invocations of the lexer, so lexer's result_symbol value would depend on what was returned from the previous call.

This PR fixes that.

@maxbrunsfeld maxbrunsfeld force-pushed the initialize-wasm-lexer-completely branch from 401c059 to 053203b Compare February 18, 2025 00:57
@maxbrunsfeld maxbrunsfeld merged commit 2bd400d into master Feb 18, 2025
13 checks passed
@maxbrunsfeld maxbrunsfeld deleted the initialize-wasm-lexer-completely branch February 18, 2025 01:36
@tree-sitter-ci-bot
Copy link

Successfully created backport PR for release-0.24:

github-actions bot pushed a commit that referenced this pull request Feb 18, 2025
@tree-sitter-ci-bot
Copy link

Git push to origin failed for release-0.24 with exitcode 1

@tree-sitter-ci-bot
Copy link

Successfully created backport PR for release-0.25:

@tree-sitter-ci-bot
Copy link

Git push to origin failed for release-0.25 with exitcode 1

maxbrunsfeld added a commit that referenced this pull request Feb 18, 2025
…ons (#4218) (#4220)

(cherry picked from commit 2bd400d)

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
maxbrunsfeld added a commit that referenced this pull request Feb 18, 2025
…ons (#4218) (#4219)

(cherry picked from commit 2bd400d)

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
maxbrunsfeld added a commit to zed-industries/zed that referenced this pull request Feb 18, 2025
…25054)

Closes #24742
Closes #24632

This PR bumps Tree-sitter to bring in bug fixes:
* tree-sitter/tree-sitter#4218
* tree-sitter/tree-sitter#4213
* tree-sitter/tree-sitter#4210

I've also bumped Wasmtime and wit-bindgen, since the new Tree-sitter
uses a newer wasmtime.

Release Notes:

- Fixed a parsing bug that caused memory leaks and crashes when using
the Ansible extension

---------

Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
jabari-max

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants