swiftwasm / swift

WebAssembly support for the Swift programming language

Home Page:https://swiftwasm.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The test executable fails to run due to call stack exhausted (swift-wasm-DEVELOPMENT-SNAPSHOT-2024-03-22-a)

kkebo opened this issue · comments

Description

Some test executables fail with the "call stack exhausted" error.

What they have in common:

  • they all have many test cases
  • the error occurs only when building with the latest (swift-wasm-DEVELOPMENT-SNAPSHOT-2024-03-22-a) toolchain
    • swift-wasm-DEVELOPMENT-SNAPSHOT-2024-03-20-a doesn't have this issue

Reproduction

Expected behavior

I expected the test executable to succeed in running.

In fact, the executable built with the previous (swift-wasm-DEVELOPMENT-SNAPSHOT-2024-03-20-a) toolchain has succeeded.

Environment

Thank you for detailed reproduction! Between the two snapshots, we introduced significant changes to XCTest to make the change acceptable for the upstream and the change includes how partial async jobs chains during the tests.

For such large scale test suites, we will recommend using tail-call enabled SDK after #5568 will be resolved.

For now, please extend stack size of wasmtime engine and C stack size in wasm binary:

# Extend stack size to 1mb
$ swift build -c release --build-tests --experimental-swift-sdk DEVELOPMENT-SNAPSHOT-2024-03-22-a-wasm -Xlinker -z -Xlinker stack-size=1048576
# 512kb (default) -> 1mb
$ wasmtime --wasm max-wasm-stack=1048576 --dir=/ .build/release/WasmTestExamplePackageTests.wasm

For now, please extend stack size of wasmtime engine and C stack size in wasm binary:

Thank you for providing a workaround. Unfortunately, I had already tried such an approach before I created the issue, but the result was the same. I gave up when I increased the size in stages up to 100 MB.

Oops, I overlooked --wasm max-wasm-stack=1048576.

@KKK669 Note that you need to increase the size of both wasmtime stack size and C stack size just in case.

Thank you so much! The 16 MiB of stack is quite large, but the test is finally working again. I'll go with it until tail-call is ready.

https://github.com/kkk669/swift-syntax/actions/runs/8437995545/job/23109088958