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

can't represent 65536 pages #2187

Closed
nlewycky opened this issue Mar 15, 2021 · 0 comments · Fixed by #2677
Closed

can't represent 65536 pages #2187

nlewycky opened this issue Mar 15, 2021 · 0 comments · Fixed by #2677
Assignees
Labels
bug Something isn't working 🏆 fuzzer-trophy Bugs found automatically by fuzzers. 📦 lib-types About wasmer-types 📦 lib-vm About wasmer-vm priority-high High priority issue
Milestone

Comments

@nlewycky
Copy link
Contributor

Describe the bug

Memory minimum and maximum sizes range 0..65536 inclusive. The verifier blocks 65537 and higher. However, wasmer only works on 65535 and lower.

Testcase:

(module (memory (;0;) 65536))

fails:

$ target/release/wasmer --cranelift x.wat 
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: TryFromIntError(())', lib/vm/src/memory.rs:262:74
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The line of code in question is:

        let mem_length = memory.minimum.bytes().0.try_into().unwrap();

and the error is that 65536*65536 is 4294967296, which is the first value too large to fit in a u32.

Wasmer needs to either remove the problematic conversions to bytes keeping the value as pages, use a larger datatype for the byte count, or store it in a 'max-1' format (assuming '0' is unnecessary since we store the absence of a memory differently.)

@nlewycky nlewycky added bug Something isn't working 🏆 fuzzer-trophy Bugs found automatically by fuzzers. labels Mar 15, 2021
nlewycky added a commit that referenced this issue Mar 16, 2021
Detect and ignore more errors from singlepass about multi-value returns.
@k-nasa k-nasa mentioned this issue Apr 25, 2021
1 task
@Hywan Hywan added 📦 lib-types About wasmer-types 📦 lib-vm About wasmer-vm labels Jul 16, 2021
@syrusakbary syrusakbary added the priority-high High priority issue label Oct 20, 2021
@wchaudry wchaudry added this to the Wasmer Runtime 2.x milestone Oct 21, 2021
bors bot added a commit that referenced this issue Nov 10, 2021
2677: Support 32-bit memories with 65536 pages r=ptitSeb a=Amanieu

Fixes #2187

Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
@bors bors bot closed this as completed in 6a0b381 Nov 10, 2021
ptitSeb pushed a commit that referenced this issue Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🏆 fuzzer-trophy Bugs found automatically by fuzzers. 📦 lib-types About wasmer-types 📦 lib-vm About wasmer-vm priority-high High priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants