GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BridgeJS: Normalize wasm pointer offsets in JS by krodak · Pull Request #768 · swiftwasm/JavaScriptKit

Conversation

@krodak

@krodak krodak commented Jun 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Overview

This PR fixes signed i32 pointer handling at the Swift-to-JavaScript boundary. WebAssembly pointers can legally point above the 2 GiB line, but the JS API exposes i32 values as signed numbers. When generated BridgeJS glue or runtime helpers used those signed values directly as typed-array or DataView offsets, pointers above 0x7fff_ffff could become negative and fail with an out-of-bounds RangeError.

The change normalizes pointer offsets with >>> 0 before using them to index WebAssembly linear memory. It also canonicalizes Swift heap object wrapper identity keys so signed and unsigned representations of the same pointer do not miss the identity cache.

1. BridgeJS generated glue

Generated swift_js_init_memory, swift_js_init_memory_with_result, and released-closure debug paths now unsigned-normalize pointer inputs before creating Uint8Array views. Swift heap object wrappers normalize pointers before storing or looking up identity-cache entries.

2. Runtime helpers

Runtime DataView and typed-array helper paths now unsigned-normalize pointer offsets before reading or writing memory. This covers JSValue array decoding, object-ref decoding, result payload writes, string loading/decoding, and typed-array creation/loading.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@krodak krodak self-assigned this Jun 12, 2026
@krodak
krodak requested a review from kateinoigakukun June 12, 2026 11:55
kateinoigakukun
kateinoigakukun reviewed Jun 12, 2026
View reviewed changes
Comment thread Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Runtime/test/pointer-normalization.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@krodak
krodak force-pushed the fix/bridgejs-pointer-limitations branch 2 times, most recently from 70acd64 to c5e5a2c Compare June 12, 2026 12:28
@krodak
BridgeJS: Normalize wasm pointer offsets in JS
e3315ec
@krodak
krodak force-pushed the fix/bridgejs-pointer-limitations branch from c5e5a2c to e3315ec Compare June 12, 2026 12:44
kateinoigakukun
kateinoigakukun approved these changes Jun 12, 2026
View reviewed changes
@krodak
krodak merged commit fba3be0 into swiftwasm:main Jun 12, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@krodak krodak mentioned this pull request Nov 6, 2026
BridgeJS: Normalize pointer in swift_js_push_typed_array #828
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kateinoigakukun kateinoigakukun kateinoigakukun approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@krodak krodak

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@krodak @kateinoigakukun
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.