-
Notifications
You must be signed in to change notification settings - Fork 452
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
Validation of internal globals in const expressions is inconsistent between interpreter and spec #1522
Comments
Indeed. Please see #1525 for a fix. |
Interesting, I would have assumed the spec should be changed, not the interpreter! I guess I should mention that AFAIK all browser engines currently treat using an internal global in a segment initializer as an error. But I suppose it's safe to extend the functionality. |
I see! I wasn't aware that browsers agree with the interpreter instead of the spec. I'm also totally fine changing the spec. Since that's just codifying reality then it would be the simpler change. I'll prepare an alternative PR. |
I just tested Chrome, Safari, Firefox and they all seem to agree. Here's the test I was using segment-init-global.zip. It might be worthwhile to see what the other engines do in this case, since I seem to remember @Cyborus04 (who originally discovered this issue) mentioning a few that had a different result. |
Hi! My testing showed that wasm3 and wasmtime agree with the spec, while wasmer agrees with the tests |
Thanks @Cyborus04. That makes the issue somewhat less clear-cut. Though arguably, there is a clear majority of implementations agreeing with the tests, so I would still tend towards tweaking the spec. Do you agree? |
Yeah, I think it makes sense to update the spec. I suppose it's worth notifying those two projects too. I've opened new bugs on those projects to track. |
Coming from the very strong backwards compatibility guarantees of Rust, my instinct says to go for the less restrictive option of aligning with the spec. I don't feel too strongly either way, though, and would not consider my thoughts an "expert opinion" by any stretch of the imagination. |
Well, in fact, the backwards compatibility requirements for Wasm are even stronger than Rust's. But in this case, even the test suite said otherwise, so one could argue that the spec merely has a typo for saying something else. In any case, I put it on the agenda for the next meeting. |
Oh, are they? Interesting. I guess then, it's a question of which one is prescriptive and which is descriptive. |
The following WebAssembly module is invalid in the reference interpreter:
This was originally disallowed in #383. However, the test added in that PR was commented out.
However, the spec currently explicitly mentions that global initializers can only reference imported globals, but does not mention anything about the same for data and element segments. Module validation also seems to use
C
instead ofC'
when validating data/element segments too, indicating that they can access both internal and imported globals.The text was updated successfully, but these errors were encountered: