Skip to content

[js-api] Reject a mutable global import before allocating - #2263

Open
chicoxyzzy wants to merge 1 commit into
WebAssembly:mainfrom
chicoxyzzy:js-api-global-import-mut
Open

chicoxyzzy wants to merge 1 commit into
WebAssembly:mainfrom
chicoxyzzy:js-api-global-import-mut

Conversation

@chicoxyzzy

Copy link
Copy Markdown
Member

Fixes #2253.

read the imports ignored mut and always called global_alloc with const valtype when the value was not a Global. A var import then failed in module_instantiate, and the const global stayed in the store.

Throw a LinkError in that case before allocating. Also throw when a const import is a var Global, which is the same mismatch and used to be reported only by module_instantiate. Allocate a fresh global with the import's mut. After the var rejection, that mut is const.

A var import of a const Global is unchanged: nothing is allocated, and module_instantiate still checks the types.

The new test covers a const import of a mutable Global for i32, i64, f32, and f64.

Fixes WebAssembly#2253.

A non-Global value for a var import was passed to global_alloc as a
const global. module_instantiate then rejected the mutability mismatch
and left that global in the store. Throw a LinkError before allocating.

A const import of a var Global is the same mismatch. Throw before
appending that global. A fresh global is allocated with the import's
mut, which is const once the var case has been rejected.

This branch has not been deployed

No deployments
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.

[js-api] A mutable global import allocates a const global before LinkError

1 participant