-
Notifications
You must be signed in to change notification settings - Fork 45
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
Behavior of NaNs and Infinities passed as float/double #466
Comments
Could be deemed as "undefined behavior", which in practice throws in JS and does whatever in native? Or do we want to avoid UB as much as possible? |
We have been mostly avoiding UB as much as possible, however in this case I think it's unreasonable to fully define the behavior. Even trying to specify it as a crash gets into too many details (what if you catch the Wasm trap and handle it somehow, what if you re-enter Wasm from a new entrypoint; in native, what if you have signal handlers, etc.) |
Dec 12 meeting:
|
I should make a list of what this applies to exactly. |
Here's the list of all floats and doubles:
To be more precise we should say it may cause an exception in wasm. On the off chance that either the JS spec changes or some wasm implementation wants to avoid crashing on non-finite inputs. |
Needs only docs. |
The JS API throws an exception (or rejects a promise with an exception) if NaN or Infinity is passed into any float/double (this rule comes from WebIDL; we don't use
unrestricted
which would lift it).What should webgpu.h do when NaN or Infinity is passed to a required float/double, or Infinity is passed to an optional float/double (
depthClearValue
)?The obvious answer is to produce a regular validation error, but Wasm implementations would technically need to detect these and inject them into the error scope. In practice, this is really unnecessary and impractical, so Wasm implementations would probably just crash by hitting the aforementioned JS exception. We could maybe say "may crash, and if not produces a validation error" I guess?
Forked from isnan question on #427.
The text was updated successfully, but these errors were encountered: