Skip to content

Conversation

@Gentle
Copy link
Contributor

@Gentle Gentle commented Jan 19, 2025

only enables the wasmtime feature, which allows initializing Modules that were compiled with newer llvm versions but don't actually use reference-types

@Gentle
Copy link
Contributor Author

Gentle commented Jan 19, 2025

I tried with my own code and could successfully initialize a Module that errors without the option.

Since there is nothing actually implemented, I set the default to false and keep the feature disabled for fuzzers, I hope that is correct

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Can you extend the wasm_validate function to disallow the following reference-types instructions:

  • ref.null
  • ref.is_null
  • the typed variant of select
  • ref.func
  • table.get
  • table.set
  • table.size
  • table.grow
  • table.fill
  • table.init
  • table.copy

?

And also please add the following tests:

  • a table-modifying instruction is used when reference-types are enabled, but the wasm is still rejected
  • reference-types are enabled and an instruction encoding that requires reference-types is used for an instruction which doesn't actually mutate tables or manipulate references, and therefore wizer succeeds (for example, a call_indirect using a non-zero table index)

Thanks!

@Gentle Gentle force-pushed the enable_reference_types branch from b1921f0 to 5fca98b Compare January 24, 2025 21:39
@Gentle
Copy link
Contributor Author

Gentle commented Jan 25, 2025

I hope I added everything

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Thanks! Two minor things and then we can merge this.

@Gentle
Copy link
Contributor Author

Gentle commented Jan 28, 2025

I hope I did it right, this seems to use the new call_indirect and the second table

@Gentle
Copy link
Contributor Author

Gentle commented Jan 28, 2025

as expected the test now goes red if I disable reference-types, so it uses the right call now :)

Edit: actually that statement is not neccessarily true, with reference types disabled it already rejects the existence of a second table, but still, the fact that call_indirect finds the second table means it should be the new call_indirect

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Thanks!

@blaine-arcjet
Copy link

blaine-arcjet commented Feb 7, 2025

@fitzgen Is this still waiting on changes before it can be merged and released? We'd like to upgrade Rust but Wizer not supporting Rust 1.81+ wasm output is a blocker.

@Gentle
Copy link
Contributor Author

Gentle commented Feb 12, 2025

I'd also like to depend on the npm packages again soon, is there anything else that would need to happen before a new wizer release?

@tschneidereit
Copy link
Member

The tests are currently failing on Windows. @Gentle, is that something you can look into to unblock landing this PR?

@Gentle
Copy link
Contributor Author

Gentle commented Feb 16, 2025

looking into it as soon as I get rust installed on the only PC with windows ;)

@Gentle
Copy link
Contributor Author

Gentle commented Feb 16, 2025

@tschneidereit rebasing onto #127 (ie. updating wasmtime) fixes the tests on Windows, the crash was deep in wasmtime code which led me to updating first before debugging

does anything speak against just bumping wasmtime instead of debugging an apparently fixed bug?

@tschneidereit
Copy link
Member

I think updating wasmtime makes a lot of sense, yes. @fitzgen, any concerns?

@fitzgen
Copy link
Member

fitzgen commented Feb 26, 2025

This can be rebased now to get CI passing since the wasmtime update merged -- thanks!

@Gentle Gentle force-pushed the enable_reference_types branch from d2b1c77 to 27e0fd2 Compare February 26, 2025 18:25
@tschneidereit
Copy link
Member

One thing I'm realizing belatedly: should this be enabled by default? I can't really think of a scenario in which I wouldn't want to enable it, since it's increasingly required to make any content work with Wizer at all.

@Gentle
Copy link
Contributor Author

Gentle commented Feb 26, 2025

I thought the same, there is never a reason to have this set to false, realistically. I would love to change the default

@fitzgen fitzgen merged commit 46dccb9 into bytecodealliance:main Feb 26, 2025
17 checks passed
@fitzgen
Copy link
Member

fitzgen commented Feb 26, 2025

Happy to have a follow up to enable it and bulk-memory by default.

alexcrichton pushed a commit to alexcrichton/wizer that referenced this pull request Oct 8, 2025
* add option for reference_types

only enables the wasmtime feature, which allows initializing Modules
that were compiled with newer llvm versions but don't actually use
reference_types

Disabled by default

* Update src/lib.rs

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>

* reject reference-types related instructions

* add setter for wasm_reference_types

* bail instead of unreachable

* tests for reference-types still rejecting tyble modifying instructions

* better error messages

* test indirect call with reference_types enabled

* same docstring for library and cli

* (hopefully) actually use the new call_indirect

---------

Co-authored-by: Gentle <ramon.klass@gmail.com>
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
alexcrichton pushed a commit to alexcrichton/wizer that referenced this pull request Oct 8, 2025
* add option for reference_types

only enables the wasmtime feature, which allows initializing Modules
that were compiled with newer llvm versions but don't actually use
reference_types

Disabled by default

* Update src/lib.rs

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>

* reject reference-types related instructions

* add setter for wasm_reference_types

* bail instead of unreachable

* tests for reference-types still rejecting tyble modifying instructions

* better error messages

* test indirect call with reference_types enabled

* same docstring for library and cli

* (hopefully) actually use the new call_indirect

---------

Co-authored-by: Gentle <ramon.klass@gmail.com>
Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
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.

4 participants