-
Notifications
You must be signed in to change notification settings - Fork 261
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
WASM compilation error due to loop unrolling #615
Comments
hrxi
added a commit
to hrxi/ark-algebra
that referenced
this issue
Feb 27, 2024
Disable loop unrolling for `Fp::into_bigint` that led to WASM miscompilations with too many local variables: ``` Error: failed to deserialize wasm module Caused by: 0: failed to parse code section 1: locals exceed maximum (at offset 16977) ``` Issue diagnosed by @paberr and @ii-cruz. Fixes arkworks-rs#615.
hrxi
added a commit
to hrxi/ark-algebra
that referenced
this issue
Feb 27, 2024
Disable loop unrolling for `Fp::into_bigint` that led to WASM miscompilations with too many local variables: ``` Error: failed to deserialize wasm module Caused by: 0: failed to parse code section 1: locals exceed maximum (at offset 16977) ``` Issue diagnosed by @paberr and @ii-cruz. Fixes arkworks-rs#615.
hrxi
added a commit
to hrxi/ark-algebra
that referenced
this issue
Feb 27, 2024
Disable loop unrolling for `Fp::into_bigint` that led to WASM miscompilations with too many local variables: ``` Error: failed to deserialize wasm module Caused by: 0: failed to parse code section 1: locals exceed maximum (at offset 16977) ``` Issue diagnosed by @paberr and @ii-cruz. Fixes arkworks-rs#615.
github-merge-queue bot
pushed a commit
that referenced
this issue
Feb 27, 2024
Disable loop unrolling for `Fp::into_bigint` that led to WASM miscompilations with too many local variables: ``` Error: failed to deserialize wasm module Caused by: 0: failed to parse code section 1: locals exceed maximum (at offset 16977) ``` Issue diagnosed by @paberr and @ii-cruz. Fixes #615. Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems that the loop unrolling on the
Fp::into_bigint
function results in an excessive number of local variables.@ii-cruz and I have created a minimal example showcasing this problem: https://github.com/paberr/arkworks-example/blob/main/tests/test.rs
Steps to reproduce
wasm-pack
wasm-pack test --node
This will fail with the following error:
Troubleshooting
This error indicates that a function tries to allocate more than 50,000 local variables.
This problem initially occurred in a larger codebase and we traced it back to the
into_bigint
function.Using the minimal example, the behaviour is reproducible.
We initially suspected that this happens due to excessive code inlining.
However, using a patched version of
ark-ff
, we found that the inlining does not trigger the error.It is the loop unrolling, which deterministically creates the error.
Removing or reducing the unrolling will make the problem disappear.
The text was updated successfully, but these errors were encountered: