Conversation
The umbrella crate (arborium) had its own crates/arborium/src/wasm.rs providing C sysroot stubs (abort, malloc, strncpy, etc.) since the initial commit. When arborium-sysroot was created in PR bearcove#161, it provided corrected implementations of the same symbols, but the old copy was never removed. This caused two problems: 1. abort() was a no-op (fn abort() {}) instead of diverging (fn abort() -> !), meaning C code calling abort() on invariant violation would continue execution past a fatal error. 2. strncpy() did not zero-pad the remainder of the destination buffer after encountering a null byte, violating the C standard. The umbrella crate compiled both its own mod wasm and depended on arborium-sysroot, producing duplicate C symbol definitions on WASM targets. Fix: delete the old wasm.rs and remove the mod wasm declaration from the umbrella lib.rs template. arborium-sysroot (already a dependency) provides the correct implementations. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
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.
Problem
The umbrella crate (
arborium) has its owncrates/arborium/src/wasm.rsproviding C sysroot stubs (abort,malloc,strncpy, etc.) since the initial commit (^16cc98a, 2025-12-01). Whenarborium-sysrootwas created in #161, it provided corrected implementations of the same symbols, but the old copy was never removed.This causes two correctness issues:
abort()is a no-op (fn abort() {}) instead of diverging (fn abort() -> !). If tree-sitter's C code callsabort()on an invariant violation via the old sysroot, execution continues past a fatal error, risking memory corruption.strncpy()missing zero-padding. The old implementation breaks on the first null byte without zero-padding the remainder of the destination buffer, violating the C standard. Thearborium-sysrootversion correctly zero-pads.The umbrella crate compiled both its own
mod wasmand depended onarborium-sysroot, producing duplicate C symbol definitions on WASM targets.Fix
crates/arborium/src/wasm.rs(510 lines of stale code)mod wasm;from the umbrellalib.rstemplate (xtask/templates/umbrella_lib.stpl.rs)arborium-sysroot(already declared as a dependency incargo.stpl.toml) provides the correct implementations.Related
arborium-sysrootwith the corrected implementations but did not remove the old copy