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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make stack size configurable #479

TorstenStueber opened this issue Dec 31, 2018 · 3 comments

Make stack size configurable #479

TorstenStueber opened this issue Dec 31, 2018 · 3 comments


Copy link

@TorstenStueber TorstenStueber commented Dec 31, 2018

馃挕 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::*;

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:

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.


This comment has been minimized.

Copy link

@alexcrichton alexcrichton commented Jan 4, 2019

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


This comment has been minimized.

Copy link

@ashleygwilliams ashleygwilliams commented Jan 18, 2019

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


This comment has been minimized.

Copy link

@TorstenStueber TorstenStueber commented Jan 25, 2019

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
None yet
3 participants
You can鈥檛 perform that action at this time.