Async-std stack overflow with Docker

I'm on Windows and when I run my Rust program it works fine. When I build a Docker image and run, though, it says:

thread 'async-std/executor' has overflowed its stack
fatal runtime error: stack overflow


# -----------------
# Cargo Build Stage
# -----------------

FROM rust:1.39 as cargo-build

WORKDIR /usr/src/app
COPY Cargo.lock .
COPY Cargo.toml .
RUN mkdir .cargo
RUN cargo vendor > .cargo/config

COPY ./src src
COPY ./benches benches
RUN cargo build --release
RUN cargo install --path . --verbose

# -----------------
# Final Stage
# -----------------

FROM ubuntu

RUN apt-get update
RUN apt-get install libssl-dev -y
COPY --from=cargo-build /usr/local/cargo/bin/my_program /bin

CMD ["my_program"]

Does anyone have any ideas why this is happening? Is it because I'm building it on a Windows machine but it's running in a Linux container?

We can't say anything without looking at your source or you giving more information. What is the program doing? Please provide some more information

Which docker image are you using?

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

You can try increasing the stack with e.g.


where that number is 20*1024*1024 i.e. 20 megabytes.

If that doesn't work, you probably have an infinite recursive loop or something like that.

From my reading, this doesn't look like an async-std problem per se. The executor thread crashes because one of the tasks overflows the stack.

I'm a little confused on why it happens, this ways, to my knowledge, Linux generally has a larger stack.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.