Skip to content

Refactor KebabStr to not require unsafe code - #2548

Merged
fitzgen merged 1 commit into
bytecodealliance:mainfrom
alexcrichton:fix-kebab-str
Jun 29, 2026
Merged

fitzgen merged 1 commit into
bytecodealliance:mainfrom
alexcrichton:fix-kebab-str

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

This requires changing KebabStr's implementation internally and adjusting callers in various locations, but the overall concept remains the same. The main difference now is that KebabStr and KebabString no longer have a Borrow or ToOwned relationship, and KebabString no longer derefs to KebabStr. For making wasmparser 100% safe this seems like a reasonable tradeoff.

This additionally fixes a problem with the previous signature of KebabStr::new_unchecked which enabled UB at runtime if called with owned types such as String or Box<str> or such. While wasmparser never actually did this it was still an unsound API to expose to users, so worthwhile to fix.

This requires changing `KebabStr`'s implementation internally and
adjusting callers in various locations, but the overall concept remains
the same. The main difference now is that `KebabStr` and `KebabString`
no longer have a `Borrow` or `ToOwned` relationship, and `KebabString`
no longer derefs to `KebabStr`. For making wasmparser 100% safe this
seems like a reasonable tradeoff.

This additionally fixes a problem with the previous signature of
`KebabStr::new_unchecked` which enabled UB at runtime if called with
owned types such as `String` or `Box<str>` or such. While `wasmparser`
never actually did this it was still an unsound API to expose to users,
so worthwhile to fix.
@alexcrichton
alexcrichton requested a review from a team as a code owner June 29, 2026 15:21
@alexcrichton
alexcrichton requested review from fitzgen and removed request for a team June 29, 2026 15:21

@fitzgen fitzgen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fitzgen
fitzgen added this pull request to the merge queue Jun 29, 2026
Merged via the queue into bytecodealliance:main with commit 8a37730 Jun 29, 2026
37 checks passed
@alexcrichton
alexcrichton deleted the fix-kebab-str branch June 29, 2026 16:07
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
wasm-tools 1.253.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* Limit the element count of fixed-length lists by @eyupcanakman in bytecodealliance/wasm-tools#2537
* wasmparser: Rename BinaryReaderError to Error by @lann in bytecodealliance/wasm-tools#2546
* fix: signature lowering for strings and lists on modules with 64bit memory by @christoph-dfinity in bytecodealliance/wasm-tools#2544
* json-from-wast: name emitted files after the output stem by @eyupcanakman in bytecodealliance/wasm-tools#2542
* Refactor `KebabStr` to not require unsafe code by @alexcrichton in bytecodealliance/wasm-tools#2548
* Add CustomSectionReader -> BinaryReader conversion by @WorldSEnder in bytecodealliance/wasm-tools#2550
* wasmparser: Add Error::missing_wasm_feature by @lann in bytecodealliance/wasm-tools#2549
* fix: use ptr-sized type when returning via ptr indirection under memory64 by @christoph-dfinity in bytecodealliance/wasm-tools#2553
* Synchronize threading intrinsics with specification by @alexcrichton in bytecodealliance/wasm-tools#2554
* Remove `resource.drop async` by @alexcrichton in bytecodealliance/wasm-tools#2552
* Initial work for `versionsuffix` and `external-id` by @alexcrichton in bytecodealliance/wasm-tools#2555
* Make parsing errors downcastable by @PhoebeSzmucer in bytecodealliance/wasm-tools#2557
* Add `SourceMap::resolve_span` for resolving global span locations by @PhoebeSzmucer in bytecodealliance/wasm-tools#2559
* Render error by @PhoebeSzmucer in bytecodealliance/wasm-tools#2560
* Support `external-id` on more items by @alexcrichton in bytecodealliance/wasm-tools#2558
* Release wasm-tools 1.253.0 by @github-actions[bot] in bytecodealliance/wasm-tools#2561

## New Contributors
* @christoph-dfinity made their first contribution in bytecodealliance/wasm-tools#2544

**Full Changelog**: https://github.com/bytecodealliance/wasm-tools/compare/v1.252.0...v1.253.0</pre>
  <p>View the full release notes at <a href="https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.253.0">https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.253.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!13746
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.

2 participants