Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear intended behavior for using WebAssembly.Exception.getArg to materialize a v128 member in JS #308

Closed
ddegazio opened this issue Jun 12, 2024 · 2 comments · Fixed by #309

Comments

@ddegazio
Copy link

Per the current spec, when we call WebAssembly.Exception.getArg, we get a payload from exn_read, and invoke ToJSValue on an element of it.

From the definition of exn_read, the returned element we use for the payload is the field tuple from the exception instance, which is just some number of ordinary WebAssembly values val*.

But, in ToJSValue, we start off with this assertion:

Assert: w is not of the form v128.const v128.

Since v128 is an ordinary WebAssembly value type, it seems valid currently for one to occur in the return tuple of exn_read. But then, getArg funnels that value directly into ToJSValue, violating its invariants. I might be overlooking something? Otherwise, it seems like there should probably be a check for v128 elements in getArg which throws a TypeError.

@dschuff
Copy link
Member

dschuff commented Jun 12, 2024

Yes, I think you are exactly right. v128 values can't currently be passed to JS, and there are various other places where we throw similar TypeErrors (e.g. the GetGlobalValue algorithm, the parameter conversion steps of "call an Exported Function" and "run a host function") before we invoke ToJSValue. It might make sense to sink that check into ToJSValue itself, but I haven't checked whether there are any places where e.g. we wouldn't be able to throw from there. But assuming we don't do that, then yeah, getArg should have the check, and also the Exception constructor (because ToWebAssemblyValue has a similar assertion). I can make a fix for that.

@dschuff
Copy link
Member

dschuff commented Jun 13, 2024

Oh oops, it looks like this is the same issue as #295. Guess we just neglected to land the fix then.

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 a pull request may close this issue.

2 participants