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

Fix NaN nondeterminism #1

Open
nhynes opened this issue Dec 8, 2018 · 2 comments
Open

Fix NaN nondeterminism #1

nhynes opened this issue Dec 8, 2018 · 2 comments

Comments

@nhynes
Copy link
Contributor

nhynes commented Dec 8, 2018

We want to enable floats, but NaNs in wasm are nondeterministic and can cause consensus failure. We need to comprehensively patch all of the cases in which nondeterminism is visible.

According to LLVM, NaNs can be canonicalized by multiplying by 1. In Rust, it's possible to do this while avoiding constant folding using test::black_box(1f64 * arg).

@Yawning seems to be the resident expert on this topic and should likely be the judge of whether the implementation is satisfactory.

@nhynes
Copy link
Contributor Author

nhynes commented Dec 8, 2018

Most interesting changes would have to happen in runner.rs. Perhaps run_store, run_reinterpret, run_trunc, run_extend, run_const.

I maybe wouldn't worry about run_call to externs since we control those functions. We do have an expf extern, but that can only return Inf if not already given a NaN.

@nhynes
Copy link
Contributor Author

nhynes commented Dec 8, 2018

As a side-note, we don't really need nan-preserving-float since we don't actually use x87 (ref).

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

No branches or pull requests

1 participant