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

Make stack size configurable #479

Closed
TorstenStueber opened this issue Dec 31, 2018 · 3 comments
Closed

Make stack size configurable #479

TorstenStueber opened this issue Dec 31, 2018 · 3 comments

Comments

@TorstenStueber
Copy link

💡 Feature description

Currently the stack-size for local variables of the generated wasm code is preconfigured to be 1048576 bytes. It is easy to reach this limit, e.g., the following program:

extern crate wasm_bindgen;

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn start() {
    let _x = Box::new([[0; 87382]; 2]);
}

will require a stack of size of 1048584 – 8 bytes larger than the configured size. The generated wasm code will then try to access negative addresses in the linear memory and will throw an error RuntimeError: "index out of bounds".

I tried all kinds of options to configure the stack size, but to no avail. For exampe I used the .cargo/config file to change the stack size:

[target.wasm32-unknown-unknown]
rustflags = [
  "-C", "link-args=-z stack-size=1500000",
]

However, the generated wasm code will always use a stack size of 1048576 bytes and will throw an error.

@alexcrichton
Copy link
Contributor

Unfortunately the Rust compiler doesn't currently have a great default way to change the stack size right now. The stack size is configured by the linker currently (LLD), and what you've passed here is basically what you would otherwise need to do to change it, but it's a bug in the Rust compiler that it's not working.

I think I've fixed this at rust-lang/rust#57337

@ashleygwilliams ashleygwilliams removed enhancement New feature or request feature request labels Jan 18, 2019
@ashleygwilliams
Copy link
Member

@TorstenStueber could you let us know if you've seen the fix improve this behavior? any sort of update would be great :) thanks!

@TorstenStueber
Copy link
Author

I can confirm that is works now using the above setting in .cargo/config. Good job! 👍

@ashleygwilliams feel free to close this issue if there is nothing to add from your side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants