You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Validation of internal globals in const expressions is inconsistent between interpreter and spec #1522
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 of C' when validating data/element segments too, indicating that they can access both internal and imported globals.
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.
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.
I would still tend towards tweaking the spec. Do you agree?
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.
Activity
rossberg commentedon Aug 23, 2022
Indeed. Please see #1525 for a fix.
binji commentedon Aug 23, 2022
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.
rossberg commentedon Aug 23, 2022
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.
binji commentedon Aug 23, 2022
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.
Cyborus04 commentedon Aug 23, 2022
Hi! My testing showed that wasm3 and wasmtime agree with the spec, while wasmer agrees with the tests
rossberg commentedon Aug 23, 2022
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?
binji commentedon Aug 24, 2022
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.
Cyborus04 commentedon Aug 24, 2022
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.
rossberg commentedon Aug 25, 2022
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.
Cyborus04 commentedon Aug 25, 2022
Oh, are they? Interesting. I guess then, it's a question of which one is prescriptive and which is descriptive.