feat(npm): publish gauche-rs wasm package - #7
Open
DennisOSRM wants to merge 1 commit into
Open
Conversation
Track the npm package that was previously an untracked local experiment in pkg/, and fix the issues that blocked publishing it. gauche_alloc/gauche_free are new exports on the web-wasm build. classifyLine previously wrote its coordinate buffer to a hardcoded address 1024, chosen as a fallback because the module exports no __heap_base. That address is in the shadow stack region; static data starts at 1048576 and the live heap above ~2721312. Static data is only read during initialize_index_wasm, so short lines were unaffected, but past roughly 170k points the write reached the live heap and the instance died with "memory access out of bounds". classifyLine now allocates through the module allocator and frees in a finally block, which was verified up to 1M points. The package metadata declared ISC. The project is BSD-2-Clause, so correct it and ship LICENSE and a README in the tarball. Also add allow(clippy::not_unsafe_ptr_arg_deref) to the two extern "C" functions taking raw pointers. The one on classify_line_wasm is pre-existing; cargo clippy against wasm32-unknown-unknown now passes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0152BLSwmtKX4pQmiLpd8wKN
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.
Turns the untracked
pkg/experiment into a publishable npm package and fixes what was wrong with it.classifyLine could kill the wasm instance
The wrapper wrote its coordinate buffer to a hardcoded address
1024, a fallback chosen because the module exports no__heap_base. Parsing the module's layout:0–10485761048576–2721312~2721312Address 1024 sits in the shadow stack. Static data gets overwritten for large lines, but
initialize_index_wasmparses the OSM string and bitmap onto the heap and never reads the static copies again, so this was invisible in normal use — a 100k-point line still classified 2343 grid points identically to a clean instance.Past roughly 170k points the write reaches the live heap. At 400k the instance dies:
gauche_alloc/gauche_freeare now exported from theweb-wasmblock andclassifyLineallocates through them, freeing in afinally.init()fails with an actionable message if it is handed a.wasmolder than the wrapper.Wrong license
package.jsondeclaredISC. The project is BSD-2-Clause. Corrected, andLICENSEplus a package README now ship in the tarball.Verification
End-to-end against the real wrapper, with the wasm served over HTTP so
fetchandinstantiateStreamingtake their genuine paths:cargo test16 passed;cargo fmt --checkcleannpm pack: 6 files, 71.0 kB packed.Also
allow(clippy::not_unsafe_ptr_arg_deref)on the twoextern "C"fns taking raw pointers. The one onclassify_line_wasmis pre-existing onmain; clippy againstwasm32-unknown-unknownnow passes. CI only runscargo fmt, so this was never gating.The
dist/gauche-wasm-map.htmldiff is the embedded wasm picking up the two new exports.🤖 Generated with Claude Code
https://claude.ai/code/session_0152BLSwmtKX4pQmiLpd8wKN