Skip to content

Remove stale duplicate WASM sysroot from umbrella crate - #205

Open
SebTardif wants to merge 1 commit into
bearcove:mainfrom
SebTardif:fix/remove-stale-wasm-sysroot
Open

SebTardif wants to merge 1 commit into
bearcove:mainfrom
SebTardif:fix/remove-stale-wasm-sysroot

Conversation

@SebTardif

Copy link
Copy Markdown

Problem

The umbrella crate (arborium) has its own crates/arborium/src/wasm.rs providing C sysroot stubs (abort, malloc, strncpy, etc.) since the initial commit (^16cc98a, 2025-12-01). When arborium-sysroot was created in #161, it provided corrected implementations of the same symbols, but the old copy was never removed.

This causes two correctness issues:

  1. abort() is a no-op (fn abort() {}) instead of diverging (fn abort() -> !). If tree-sitter's C code calls abort() on an invariant violation via the old sysroot, execution continues past a fatal error, risking memory corruption.

  2. 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. The arborium-sysroot version correctly zero-pads.

The umbrella crate compiled both its own mod wasm and depended on arborium-sysroot, producing duplicate C symbol definitions on WASM targets.

Fix

  • Delete crates/arborium/src/wasm.rs (510 lines of stale code)
  • Remove mod wasm; from the umbrella lib.rs template (xtask/templates/umbrella_lib.stpl.rs)

arborium-sysroot (already declared as a dependency in cargo.stpl.toml) provides the correct implementations.

Related

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>
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