swiftwasm / swift

WebAssembly support for the Swift programming language
https://swiftwasm.org
1.28k stars 28 forks source link

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

Closed kkebo closed 3 months ago

kkebo commented 3 months ago

Description

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

What they have in common:

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

kateinoigakukun commented 3 months ago

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 https://github.com/swiftwasm/swift/issues/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
kkebo commented 3 months ago

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.

kkebo commented 3 months ago

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

kateinoigakukun commented 3 months ago

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

kkebo commented 3 months ago

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