fix(wasm): load supertype tables for ABI 15 grammars (#5605) (#5606)

The wasm store gated supertype_symbols / supertype_map_slices /
supertype_map_entries copies on abi_version > LANGUAGE_VERSION_WITH_RESERVED_WORDS,
but every other consumer (language.c, query.c) treats those tables as
present when abi_version >= LANGUAGE_VERSION_WITH_RESERVED_WORDS.

A Wasm grammar built at ABI exactly 15 with supertype_count > 0 ends up
with supertype_count copied into the native TSLanguage but supertype_map_slices
left NULL. ts_query__analyze_patterns then calls ts_language_subtypes,
which dereferences self->supertype_map_slices[supertype] and crashes.

(cherry picked from commit a53c3b03a0)

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
tree-sitter-ci-bot[bot] 2026-05-18 13:58:51 -07:00 committed by GitHub
parent 2cad8b8d47
commit 7aea01521d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1215,7 +1215,7 @@ const TSLanguage *ts_wasm_store_load_language(
memcpy(&wasm_language, &memory[language_address], sizeof(LanguageInWasmMemory));
bool has_supertypes =
wasm_language.abi_version > LANGUAGE_VERSION_WITH_RESERVED_WORDS &&
wasm_language.abi_version >= LANGUAGE_VERSION_WITH_RESERVED_WORDS &&
wasm_language.supertype_count > 0;
int32_t addresses[] = {