From fecf981cdb1f6ab87bfccae55e1d0926d9bc6d5c Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 27 Mar 2026 08:12:57 +0100 Subject: [PATCH 1/7] Debug stack overflow --- Cargo.lock | 128 ++++++++++++++++++++++++++++++++++---------- Cargo.toml | 1 + tests/common/mod.rs | 20 ++++++- 3 files changed, 119 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26f8df8f..3d7857ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,13 +2,22 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "addr2line" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" +dependencies = [ + "gimli 0.32.3", +] + [[package]] name = "addr2line" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9698bf0769c641b18618039fe2ebd41eb3541f98433000f64e663fab7cea2c87" dependencies = [ - "gimli", + "gimli 0.33.0", ] [[package]] @@ -189,6 +198,32 @@ dependencies = [ "tracing", ] +[[package]] +name = "backtrace" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" +dependencies = [ + "addr2line 0.25.1", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-link 0.2.1", +] + +[[package]] +name = "backtrace-on-stack-overflow" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd2d70527f3737a1ad17355e260706c1badebabd1fa06a7a053407380df841b" +dependencies = [ + "backtrace", + "libc", + "nix", +] + [[package]] name = "base64" version = "0.22.1" @@ -208,6 +243,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.11.0" @@ -586,7 +627,7 @@ dependencies = [ "cranelift-control", "cranelift-entity", "cranelift-isle", - "gimli", + "gimli 0.33.0", "hashbrown 0.15.4", "libm", "log", @@ -1136,7 +1177,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25234f20a3ec0a962a61770cfe39ecf03cb529a6e474ad8cff025ed497eda557" dependencies = [ - "bitflags", + "bitflags 2.11.0", "debugid", "rustc-hash", "serde", @@ -1191,6 +1232,12 @@ dependencies = [ "wasip3", ] +[[package]] +name = "gimli" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" + [[package]] name = "gimli" version = "0.33.0" @@ -1680,7 +1727,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1580801010e535496706ba011c15f8532df6b42297d2e471fec38ceadd8c0638" dependencies = [ - "bitflags", + "bitflags 2.11.0", "libc", ] @@ -1754,6 +1801,15 @@ dependencies = [ "rustix 1.1.4", ] +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "mime" version = "0.3.17" @@ -1797,6 +1853,19 @@ dependencies = [ "version_check", ] +[[package]] +name = "nix" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +dependencies = [ + "bitflags 1.3.2", + "cc", + "cfg-if", + "libc", + "memoffset", +] + [[package]] name = "nonempty-collections" version = "0.3.1" @@ -1905,7 +1974,7 @@ version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be755331a7de00100c60e03151663f26037a0dd720be238de57c036be03b4033" dependencies = [ - "bitflags", + "bitflags 2.11.0", "oxc_allocator", "oxc_ast_macros", "oxc_data_structures", @@ -1983,7 +2052,7 @@ version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "341602ba5eb6629f7f90e49c1fce06bb8eed989412a4178acd8e7f48cf2c7f9d" dependencies = [ - "bitflags", + "bitflags 2.11.0", "cow-utils", "memchr", "num-bigint", @@ -2006,7 +2075,7 @@ version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e810182cbde172aeada70acc45dae74f6773384e0d295cc27e6e377b1fc277c" dependencies = [ - "bitflags", + "bitflags 2.11.0", "oxc_allocator", "oxc_ast_macros", "oxc_diagnostics", @@ -2048,7 +2117,7 @@ version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e77ea5bd4ea42ce05b2f51bcef8e46a4598cea5038ab25877a2d27601a90da83" dependencies = [ - "bitflags", + "bitflags 2.11.0", "cow-utils", "dragonbox_ecma", "nonmax", @@ -2412,7 +2481,7 @@ version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" dependencies = [ - "bitflags", + "bitflags 2.11.0", ] [[package]] @@ -2478,7 +2547,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags", + "bitflags 2.11.0", "errno", "libc", "linux-raw-sys 0.4.15", @@ -2491,7 +2560,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags", + "bitflags 2.11.0", "errno", "libc", "linux-raw-sys 0.12.1", @@ -2829,7 +2898,7 @@ version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc4592f674ce18521c2a81483873a49596655b179f71c5e05d10c1fe66c78745" dependencies = [ - "bitflags", + "bitflags 2.11.0", "cap-fs-ext", "cap-std", "fd-lock", @@ -3527,6 +3596,7 @@ version = "0.0.0" dependencies = [ "anyhow", "axum", + "backtrace-on-stack-overflow", "bytes", "camino", "camino-tempfile", @@ -3564,7 +3634,7 @@ version = "0.229.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cc3b1f053f5d41aa55640a1fa9b6d1b8a9e4418d118ce308d20e24ff3575a8c" dependencies = [ - "bitflags", + "bitflags 2.11.0", "hashbrown 0.15.4", "indexmap", "semver", @@ -3577,7 +3647,7 @@ version = "0.235.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "161296c618fa2d63f6ed5fffd1112937e803cb9ec71b32b01a76321555660917" dependencies = [ - "bitflags", + "bitflags 2.11.0", "hashbrown 0.15.4", "indexmap", "semver", @@ -3590,7 +3660,7 @@ version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ - "bitflags", + "bitflags 2.11.0", "hashbrown 0.15.4", "indexmap", "semver", @@ -3603,7 +3673,7 @@ version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f08c9adee0428b7bddf3890fc27e015ac4b761cc608c822667102b8bfd6995e" dependencies = [ - "bitflags", + "bitflags 2.11.0", "indexmap", "semver", ] @@ -3625,16 +3695,16 @@ version = "42.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39bef52be4fb4c5b47d36f847172e896bc94b35c9c6a6f07117686bd16ed89a7" dependencies = [ - "addr2line", + "addr2line 0.26.0", "async-trait", - "bitflags", + "bitflags 2.11.0", "bumpalo", "cc", "cfg-if", "encoding_rs", "futures", "fxprof-processed-profile", - "gimli", + "gimli 0.33.0", "ittapi", "libc", "log", @@ -3682,7 +3752,7 @@ dependencies = [ "cpp_demangle", "cranelift-bitset", "cranelift-entity", - "gimli", + "gimli 0.33.0", "hashbrown 0.15.4", "indexmap", "log", @@ -3764,7 +3834,7 @@ dependencies = [ "cranelift-entity", "cranelift-frontend", "cranelift-native", - "gimli", + "gimli 0.33.0", "itertools", "log", "object", @@ -3849,7 +3919,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9130b3ab6fb01be80b27b9a2c84817af29ae8224094f2503d2afa9fea5bf9d00" dependencies = [ "cranelift-codegen", - "gimli", + "gimli 0.33.0", "log", "object", "target-lexicon", @@ -3866,7 +3936,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "102d0d70dbfede00e4cc9c24e86df6d32c03bf6f5ad06b5d6c76b0a4a5004c4a" dependencies = [ "anyhow", - "bitflags", + "bitflags 2.11.0", "heck", "indexmap", "wit-parser 0.244.0", @@ -3879,7 +3949,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea938f6f4f11e5ffe6d8b6f34c9a994821db9511c3e9c98e535896f27d06bb92" dependencies = [ "async-trait", - "bitflags", + "bitflags 2.11.0", "bytes", "cap-fs-ext", "cap-net-ext", @@ -4012,7 +4082,7 @@ version = "42.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dca2bf96d20f0c70e6741cc6c8c1a9ee4c3c0310c7ad1971242628c083cc9a5" dependencies = [ - "bitflags", + "bitflags 2.11.0", "thiserror 2.0.18", "tracing", "wasmtime", @@ -4085,7 +4155,7 @@ checksum = "1977857998e4dd70d26e2bfc0618a9684a2fb65b1eca174dc13f3b3e9c2159ca" dependencies = [ "cranelift-assembler-x64", "cranelift-codegen", - "gimli", + "gimli 0.33.0", "regalloc2", "smallvec", "target-lexicon", @@ -4273,7 +4343,7 @@ version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f3fd376f71958b862e7afb20cfe5a22830e1963462f3a17f49d82a6c1d1f42d" dependencies = [ - "bitflags", + "bitflags 2.11.0", "windows-sys 0.59.0", ] @@ -4314,7 +4384,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags", + "bitflags 2.11.0", ] [[package]] @@ -4361,7 +4431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", - "bitflags", + "bitflags 2.11.0", "indexmap", "log", "serde", diff --git a/Cargo.toml b/Cargo.toml index 405d6541..692f596b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ tokio = { workspace = true, features = ["rt"] } [dev-dependencies] anyhow = { workspace = true } axum = { workspace = true, features = ["multipart"] } +backtrace-on-stack-overflow = "0.3.0" bytes = { workspace = true } camino-tempfile = { workspace = true } chrono = { workspace = true } diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 646f8cfb..d282cf78 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -11,7 +11,7 @@ use std::collections::{BTreeMap, BTreeSet}; use std::fs; use std::io::Write; use std::process::Command; -use std::sync::{Arc, Mutex}; +use std::sync::{Arc, Mutex, Once}; use std::time::{Duration, Instant}; use tokio::time::timeout; use wac_graph::types::{Package, SubtypeChecker}; @@ -26,6 +26,20 @@ use wasmtime_wasi::p2::bindings; use wasmtime_wasi::{DirPerms, FilePerms, WasiCtx, WasiCtxView, WasiView}; use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView}; +#[cfg(unix)] +fn enable_stack_overflow_backtrace() { + static ENABLED: Once = Once::new(); + + ENABLED.call_once(|| unsafe { + // Best-effort diagnostic for CI-only stack overflows in the Rust test + // process. Keep this in test code only. + backtrace_on_stack_overflow::enable(); + }); +} + +#[cfg(not(unix))] +fn enable_stack_overflow_backtrace() {} + /// Strip JSONC comments (// and /* */) while respecting string literals. pub fn strip_jsonc_comments(input: &str) -> String { let mut result = String::with_capacity(input.len()); @@ -228,6 +242,8 @@ pub struct PreparedComponent { impl PreparedComponent { pub fn new(wasm_path: &Utf8Path) -> anyhow::Result { + enable_stack_overflow_backtrace(); + let mut config = wasmtime::Config::default(); config.wasm_component_model(true); config.epoch_interruption(true); @@ -319,6 +335,8 @@ pub struct GolemPreparedComponent { impl GolemPreparedComponent { pub fn new(wasm_path: &Utf8Path) -> anyhow::Result { + enable_stack_overflow_backtrace(); + let mut config = wasmtime::Config::default(); config.wasm_component_model(true); config.async_stack_size(32 * 1024 * 1024); From bb496d90aba3ef8a618f037537d957bb755ebd86 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 27 Mar 2026 08:54:48 +0100 Subject: [PATCH 2/7] Debug with gdb --- .../scripts/run-runtime-group-under-gdb.sh | 67 +++++++++ .github/workflows/ci.yaml | 15 +- Cargo.lock | 128 ++++-------------- Cargo.toml | 1 - tests/common/mod.rs | 20 +-- 5 files changed, 111 insertions(+), 120 deletions(-) create mode 100644 .github/scripts/run-runtime-group-under-gdb.sh diff --git a/.github/scripts/run-runtime-group-under-gdb.sh b/.github/scripts/run-runtime-group-under-gdb.sh new file mode 100644 index 00000000..3d5f8d3e --- /dev/null +++ b/.github/scripts/run-runtime-group-under-gdb.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ $# -ne 1 ]]; then + echo "usage: $0 " >&2 + exit 2 +fi + +group="$1" +mkdir -p target + +if ! command -v gdb >/dev/null 2>&1; then + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update + sudo apt-get install -y gdb +fi + +cargo test --test runtime --no-run + +test_bin="$({ + find target/debug/deps -maxdepth 1 -type f -name 'runtime-*' -executable -printf '%T@ %p\n' 2>/dev/null || true +} | sort -n | tail -n1 | cut -d' ' -f2-)" + +if [[ -z "${test_bin}" ]]; then + echo "failed to locate runtime test binary under target/debug/deps" >&2 + exit 1 +fi + +gdb_cmds="target/gdb-runtime-group${group}.cmds" +gdb_log="target/gdb-runtime-group${group}.log" + +cat > "${gdb_cmds}" <<'EOF' +set confirm off +set pagination off +set print thread-events off +set debuginfod enabled off +handle SIGSEGV stop print nopass +handle SIGABRT stop print nopass +run --nocapture --report-time --format ctrf --logfile target/ctrf.json ':tag:group__GROUP__' +if $_isvoid($_exitcode) && $_isvoid($_exitsignal) + echo \n=== Thread Backtraces ===\n + thread apply all bt full + quit 1 +end +if !$_isvoid($_exitsignal) + quit 1 +end +if !$_isvoid($_exitcode) && $_exitcode != 0 + quit $_exitcode +end +quit 0 +EOF + +sed -i "s/__GROUP__/${group}/g" "${gdb_cmds}" + +set +e +timeout --signal=TERM 20m \ + gdb -q -batch -return-child-result -x "${gdb_cmds}" --args "${test_bin}" \ + 2>&1 | tee "${gdb_log}" +status=${PIPESTATUS[0]} +set -e + +if [[ ${status} -eq 124 ]]; then + echo "gdb timed out after 20 minutes" >&2 +fi + +exit "${status}" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1309c8eb..2afbf5c5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -72,11 +72,24 @@ jobs: with: submodules: true - uses: ./.github/actions/setup + - name: Runtime tests under gdb (groups 1-2) + if: matrix.group == 1 || matrix.group == 2 + run: bash .github/scripts/run-runtime-group-under-gdb.sh ${{ matrix.group }} - name: Runtime tests (group ${{ matrix.group }}/8) + if: matrix.group != 1 && matrix.group != 2 run: cargo test --test runtime -- --nocapture --report-time --format ctrf --logfile target/ctrf.json ':tag:group${{ matrix.group }}' + - name: Upload gdb log + uses: actions/upload-artifact@v4 + if: always() && (matrix.group == 1 || matrix.group == 2) + with: + name: test-runtime-group-${{ matrix.group }}-gdb-log + path: | + target/gdb-runtime-group${{ matrix.group }}.log + target/gdb-runtime-group${{ matrix.group }}.cmds + if-no-files-found: warn - name: Publish Test Report uses: ctrf-io/github-test-reporter@v1 - if: always() + if: always() && matrix.group != 1 && matrix.group != 2 with: report-path: "**/target/ctrf-*.json" upload-artifact: "true" diff --git a/Cargo.lock b/Cargo.lock index 3d7857ce..26f8df8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,22 +2,13 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "addr2line" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" -dependencies = [ - "gimli 0.32.3", -] - [[package]] name = "addr2line" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9698bf0769c641b18618039fe2ebd41eb3541f98433000f64e663fab7cea2c87" dependencies = [ - "gimli 0.33.0", + "gimli", ] [[package]] @@ -198,32 +189,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "backtrace" -version = "0.3.76" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" -dependencies = [ - "addr2line 0.25.1", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-link 0.2.1", -] - -[[package]] -name = "backtrace-on-stack-overflow" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd2d70527f3737a1ad17355e260706c1badebabd1fa06a7a053407380df841b" -dependencies = [ - "backtrace", - "libc", - "nix", -] - [[package]] name = "base64" version = "0.22.1" @@ -243,12 +208,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.11.0" @@ -627,7 +586,7 @@ dependencies = [ "cranelift-control", "cranelift-entity", "cranelift-isle", - "gimli 0.33.0", + "gimli", "hashbrown 0.15.4", "libm", "log", @@ -1177,7 +1136,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25234f20a3ec0a962a61770cfe39ecf03cb529a6e474ad8cff025ed497eda557" dependencies = [ - "bitflags 2.11.0", + "bitflags", "debugid", "rustc-hash", "serde", @@ -1232,12 +1191,6 @@ dependencies = [ "wasip3", ] -[[package]] -name = "gimli" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" - [[package]] name = "gimli" version = "0.33.0" @@ -1727,7 +1680,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1580801010e535496706ba011c15f8532df6b42297d2e471fec38ceadd8c0638" dependencies = [ - "bitflags 2.11.0", + "bitflags", "libc", ] @@ -1801,15 +1754,6 @@ dependencies = [ "rustix 1.1.4", ] -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "mime" version = "0.3.17" @@ -1853,19 +1797,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "nix" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" -dependencies = [ - "bitflags 1.3.2", - "cc", - "cfg-if", - "libc", - "memoffset", -] - [[package]] name = "nonempty-collections" version = "0.3.1" @@ -1974,7 +1905,7 @@ version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be755331a7de00100c60e03151663f26037a0dd720be238de57c036be03b4033" dependencies = [ - "bitflags 2.11.0", + "bitflags", "oxc_allocator", "oxc_ast_macros", "oxc_data_structures", @@ -2052,7 +1983,7 @@ version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "341602ba5eb6629f7f90e49c1fce06bb8eed989412a4178acd8e7f48cf2c7f9d" dependencies = [ - "bitflags 2.11.0", + "bitflags", "cow-utils", "memchr", "num-bigint", @@ -2075,7 +2006,7 @@ version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e810182cbde172aeada70acc45dae74f6773384e0d295cc27e6e377b1fc277c" dependencies = [ - "bitflags 2.11.0", + "bitflags", "oxc_allocator", "oxc_ast_macros", "oxc_diagnostics", @@ -2117,7 +2048,7 @@ version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e77ea5bd4ea42ce05b2f51bcef8e46a4598cea5038ab25877a2d27601a90da83" dependencies = [ - "bitflags 2.11.0", + "bitflags", "cow-utils", "dragonbox_ecma", "nonmax", @@ -2481,7 +2412,7 @@ version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" dependencies = [ - "bitflags 2.11.0", + "bitflags", ] [[package]] @@ -2547,7 +2478,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.11.0", + "bitflags", "errno", "libc", "linux-raw-sys 0.4.15", @@ -2560,7 +2491,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.11.0", + "bitflags", "errno", "libc", "linux-raw-sys 0.12.1", @@ -2898,7 +2829,7 @@ version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc4592f674ce18521c2a81483873a49596655b179f71c5e05d10c1fe66c78745" dependencies = [ - "bitflags 2.11.0", + "bitflags", "cap-fs-ext", "cap-std", "fd-lock", @@ -3596,7 +3527,6 @@ version = "0.0.0" dependencies = [ "anyhow", "axum", - "backtrace-on-stack-overflow", "bytes", "camino", "camino-tempfile", @@ -3634,7 +3564,7 @@ version = "0.229.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cc3b1f053f5d41aa55640a1fa9b6d1b8a9e4418d118ce308d20e24ff3575a8c" dependencies = [ - "bitflags 2.11.0", + "bitflags", "hashbrown 0.15.4", "indexmap", "semver", @@ -3647,7 +3577,7 @@ version = "0.235.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "161296c618fa2d63f6ed5fffd1112937e803cb9ec71b32b01a76321555660917" dependencies = [ - "bitflags 2.11.0", + "bitflags", "hashbrown 0.15.4", "indexmap", "semver", @@ -3660,7 +3590,7 @@ version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ - "bitflags 2.11.0", + "bitflags", "hashbrown 0.15.4", "indexmap", "semver", @@ -3673,7 +3603,7 @@ version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f08c9adee0428b7bddf3890fc27e015ac4b761cc608c822667102b8bfd6995e" dependencies = [ - "bitflags 2.11.0", + "bitflags", "indexmap", "semver", ] @@ -3695,16 +3625,16 @@ version = "42.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39bef52be4fb4c5b47d36f847172e896bc94b35c9c6a6f07117686bd16ed89a7" dependencies = [ - "addr2line 0.26.0", + "addr2line", "async-trait", - "bitflags 2.11.0", + "bitflags", "bumpalo", "cc", "cfg-if", "encoding_rs", "futures", "fxprof-processed-profile", - "gimli 0.33.0", + "gimli", "ittapi", "libc", "log", @@ -3752,7 +3682,7 @@ dependencies = [ "cpp_demangle", "cranelift-bitset", "cranelift-entity", - "gimli 0.33.0", + "gimli", "hashbrown 0.15.4", "indexmap", "log", @@ -3834,7 +3764,7 @@ dependencies = [ "cranelift-entity", "cranelift-frontend", "cranelift-native", - "gimli 0.33.0", + "gimli", "itertools", "log", "object", @@ -3919,7 +3849,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9130b3ab6fb01be80b27b9a2c84817af29ae8224094f2503d2afa9fea5bf9d00" dependencies = [ "cranelift-codegen", - "gimli 0.33.0", + "gimli", "log", "object", "target-lexicon", @@ -3936,7 +3866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "102d0d70dbfede00e4cc9c24e86df6d32c03bf6f5ad06b5d6c76b0a4a5004c4a" dependencies = [ "anyhow", - "bitflags 2.11.0", + "bitflags", "heck", "indexmap", "wit-parser 0.244.0", @@ -3949,7 +3879,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea938f6f4f11e5ffe6d8b6f34c9a994821db9511c3e9c98e535896f27d06bb92" dependencies = [ "async-trait", - "bitflags 2.11.0", + "bitflags", "bytes", "cap-fs-ext", "cap-net-ext", @@ -4082,7 +4012,7 @@ version = "42.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dca2bf96d20f0c70e6741cc6c8c1a9ee4c3c0310c7ad1971242628c083cc9a5" dependencies = [ - "bitflags 2.11.0", + "bitflags", "thiserror 2.0.18", "tracing", "wasmtime", @@ -4155,7 +4085,7 @@ checksum = "1977857998e4dd70d26e2bfc0618a9684a2fb65b1eca174dc13f3b3e9c2159ca" dependencies = [ "cranelift-assembler-x64", "cranelift-codegen", - "gimli 0.33.0", + "gimli", "regalloc2", "smallvec", "target-lexicon", @@ -4343,7 +4273,7 @@ version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f3fd376f71958b862e7afb20cfe5a22830e1963462f3a17f49d82a6c1d1f42d" dependencies = [ - "bitflags 2.11.0", + "bitflags", "windows-sys 0.59.0", ] @@ -4384,7 +4314,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.11.0", + "bitflags", ] [[package]] @@ -4431,7 +4361,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", - "bitflags 2.11.0", + "bitflags", "indexmap", "log", "serde", diff --git a/Cargo.toml b/Cargo.toml index 692f596b..405d6541 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ tokio = { workspace = true, features = ["rt"] } [dev-dependencies] anyhow = { workspace = true } axum = { workspace = true, features = ["multipart"] } -backtrace-on-stack-overflow = "0.3.0" bytes = { workspace = true } camino-tempfile = { workspace = true } chrono = { workspace = true } diff --git a/tests/common/mod.rs b/tests/common/mod.rs index d282cf78..646f8cfb 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -11,7 +11,7 @@ use std::collections::{BTreeMap, BTreeSet}; use std::fs; use std::io::Write; use std::process::Command; -use std::sync::{Arc, Mutex, Once}; +use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; use tokio::time::timeout; use wac_graph::types::{Package, SubtypeChecker}; @@ -26,20 +26,6 @@ use wasmtime_wasi::p2::bindings; use wasmtime_wasi::{DirPerms, FilePerms, WasiCtx, WasiCtxView, WasiView}; use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView}; -#[cfg(unix)] -fn enable_stack_overflow_backtrace() { - static ENABLED: Once = Once::new(); - - ENABLED.call_once(|| unsafe { - // Best-effort diagnostic for CI-only stack overflows in the Rust test - // process. Keep this in test code only. - backtrace_on_stack_overflow::enable(); - }); -} - -#[cfg(not(unix))] -fn enable_stack_overflow_backtrace() {} - /// Strip JSONC comments (// and /* */) while respecting string literals. pub fn strip_jsonc_comments(input: &str) -> String { let mut result = String::with_capacity(input.len()); @@ -242,8 +228,6 @@ pub struct PreparedComponent { impl PreparedComponent { pub fn new(wasm_path: &Utf8Path) -> anyhow::Result { - enable_stack_overflow_backtrace(); - let mut config = wasmtime::Config::default(); config.wasm_component_model(true); config.epoch_interruption(true); @@ -335,8 +319,6 @@ pub struct GolemPreparedComponent { impl GolemPreparedComponent { pub fn new(wasm_path: &Utf8Path) -> anyhow::Result { - enable_stack_overflow_backtrace(); - let mut config = wasmtime::Config::default(); config.wasm_component_model(true); config.async_stack_size(32 * 1024 * 1024); From 068bb69413eaa8bb5f3f38f365a7975c3900e975 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 27 Mar 2026 09:45:31 +0100 Subject: [PATCH 3/7] Debug --- .../scripts/run-runtime-group-under-gdb.sh | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/scripts/run-runtime-group-under-gdb.sh b/.github/scripts/run-runtime-group-under-gdb.sh index 3d5f8d3e..ab470bc4 100644 --- a/.github/scripts/run-runtime-group-under-gdb.sh +++ b/.github/scripts/run-runtime-group-under-gdb.sh @@ -33,13 +33,20 @@ cat > "${gdb_cmds}" <<'EOF' set confirm off set pagination off set print thread-events off +set print frame-arguments none +set print elements 0 +set print repeats 0 set debuginfod enabled off handle SIGSEGV stop print nopass handle SIGABRT stop print nopass run --nocapture --report-time --format ctrf --logfile target/ctrf.json ':tag:group__GROUP__' if $_isvoid($_exitcode) && $_isvoid($_exitsignal) - echo \n=== Thread Backtraces ===\n - thread apply all bt full + echo \n=== Current Thread Backtrace ===\n + bt 40 + echo \n=== Thread List ===\n + info threads + echo \n=== Short Backtraces ===\n + thread apply all bt 8 quit 1 end if !$_isvoid($_exitsignal) @@ -56,10 +63,30 @@ sed -i "s/__GROUP__/${group}/g" "${gdb_cmds}" set +e timeout --signal=TERM 20m \ gdb -q -batch -return-child-result -x "${gdb_cmds}" --args "${test_bin}" \ - 2>&1 | tee "${gdb_log}" -status=${PIPESTATUS[0]} + > "${gdb_log}" 2>&1 +status=$? set -e +echo "gdb log written to ${gdb_log}" + +if rg -n -m 1 "received signal|Program received signal" "${gdb_log}" >/tmp/gdb-signal-summary.$$; then + echo "Crash summary:" + cat /tmp/gdb-signal-summary.$$ +fi +rm -f /tmp/gdb-signal-summary.$$ + +if rg -n -m 1 "=== Current Thread Backtrace ===" "${gdb_log}" >/tmp/gdb-backtrace-marker.$$; then + backtrace_start=$(cut -d: -f1 < /tmp/gdb-backtrace-marker.$$) + echo + echo "Current thread backtrace excerpt:" + sed -n "${backtrace_start},$((backtrace_start + 60))p" "${gdb_log}" +fi +rm -f /tmp/gdb-backtrace-marker.$$ + +echo +echo "Last 40 lines of gdb log:" +tail -n 40 "${gdb_log}" + if [[ ${status} -eq 124 ]]; then echo "gdb timed out after 20 minutes" >&2 fi From a34bbd123fc137a9b9d4c93c4aa22ab760e8434e Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 27 Mar 2026 10:07:47 +0100 Subject: [PATCH 4/7] Disable wasmtime cache --- tests/common/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 646f8cfb..65947ca5 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -233,7 +233,6 @@ impl PreparedComponent { config.epoch_interruption(true); config.async_stack_size(32 * 1024 * 1024); // 32MB async stack (must be >= max_wasm_stack) config.max_wasm_stack(16 * 1024 * 1024); // 16MB WASM stack (default is 512KB, QuickJS in WASM needs more for deep recursion) - config.cache(Some(wasmtime::Cache::from_file(None)?)); let engine = Engine::new(&config)?; // Start a background thread that increments the epoch every 10ms, @@ -323,7 +322,6 @@ impl GolemPreparedComponent { config.wasm_component_model(true); config.async_stack_size(32 * 1024 * 1024); config.max_wasm_stack(16 * 1024 * 1024); - config.cache(Some(wasmtime::Cache::from_file(None)?)); let engine = Engine::new(&config)?; let mut linker: Linker = Linker::new(&engine); From 942edd3282857513ab972de97c8dcbdb859772c2 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 27 Mar 2026 10:38:03 +0100 Subject: [PATCH 5/7] Full log --- .../scripts/run-runtime-group-under-gdb.sh | 27 +++---------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/scripts/run-runtime-group-under-gdb.sh b/.github/scripts/run-runtime-group-under-gdb.sh index ab470bc4..86bf7775 100644 --- a/.github/scripts/run-runtime-group-under-gdb.sh +++ b/.github/scripts/run-runtime-group-under-gdb.sh @@ -39,6 +39,7 @@ set print repeats 0 set debuginfod enabled off handle SIGSEGV stop print nopass handle SIGABRT stop print nopass +handle SIGILL stop print nopass run --nocapture --report-time --format ctrf --logfile target/ctrf.json ':tag:group__GROUP__' if $_isvoid($_exitcode) && $_isvoid($_exitsignal) echo \n=== Current Thread Backtrace ===\n @@ -52,10 +53,6 @@ end if !$_isvoid($_exitsignal) quit 1 end -if !$_isvoid($_exitcode) && $_exitcode != 0 - quit $_exitcode -end -quit 0 EOF sed -i "s/__GROUP__/${group}/g" "${gdb_cmds}" @@ -67,25 +64,9 @@ timeout --signal=TERM 20m \ status=$? set -e -echo "gdb log written to ${gdb_log}" - -if rg -n -m 1 "received signal|Program received signal" "${gdb_log}" >/tmp/gdb-signal-summary.$$; then - echo "Crash summary:" - cat /tmp/gdb-signal-summary.$$ -fi -rm -f /tmp/gdb-signal-summary.$$ - -if rg -n -m 1 "=== Current Thread Backtrace ===" "${gdb_log}" >/tmp/gdb-backtrace-marker.$$; then - backtrace_start=$(cut -d: -f1 < /tmp/gdb-backtrace-marker.$$) - echo - echo "Current thread backtrace excerpt:" - sed -n "${backtrace_start},$((backtrace_start + 60))p" "${gdb_log}" -fi -rm -f /tmp/gdb-backtrace-marker.$$ - -echo -echo "Last 40 lines of gdb log:" -tail -n 40 "${gdb_log}" +echo "=== gdb log (${gdb_log}) ===" +cat "${gdb_log}" +echo "=== end gdb log (exit code ${status}) ===" if [[ ${status} -eq 124 ]]; then echo "gdb timed out after 20 minutes" >&2 From f5ae9aa77fae89d163807c099f8daed2b8fba5c9 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 27 Mar 2026 11:07:11 +0100 Subject: [PATCH 6/7] CTRF report for the debugged steps too --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2afbf5c5..effcbfa7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -86,10 +86,11 @@ jobs: path: | target/gdb-runtime-group${{ matrix.group }}.log target/gdb-runtime-group${{ matrix.group }}.cmds + target/ctrf-*.json if-no-files-found: warn - name: Publish Test Report uses: ctrf-io/github-test-reporter@v1 - if: always() && matrix.group != 1 && matrix.group != 2 + if: always() with: report-path: "**/target/ctrf-*.json" upload-artifact: "true" From bfc907e2a0e373bb7bf6b9c735793703dbbf7b30 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 27 Mar 2026 11:23:57 +0100 Subject: [PATCH 7/7] Removed gdb --- .../scripts/run-runtime-group-under-gdb.sh | 75 ------------------- .github/workflows/ci.yaml | 14 ---- 2 files changed, 89 deletions(-) delete mode 100644 .github/scripts/run-runtime-group-under-gdb.sh diff --git a/.github/scripts/run-runtime-group-under-gdb.sh b/.github/scripts/run-runtime-group-under-gdb.sh deleted file mode 100644 index 86bf7775..00000000 --- a/.github/scripts/run-runtime-group-under-gdb.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -if [[ $# -ne 1 ]]; then - echo "usage: $0 " >&2 - exit 2 -fi - -group="$1" -mkdir -p target - -if ! command -v gdb >/dev/null 2>&1; then - export DEBIAN_FRONTEND=noninteractive - sudo apt-get update - sudo apt-get install -y gdb -fi - -cargo test --test runtime --no-run - -test_bin="$({ - find target/debug/deps -maxdepth 1 -type f -name 'runtime-*' -executable -printf '%T@ %p\n' 2>/dev/null || true -} | sort -n | tail -n1 | cut -d' ' -f2-)" - -if [[ -z "${test_bin}" ]]; then - echo "failed to locate runtime test binary under target/debug/deps" >&2 - exit 1 -fi - -gdb_cmds="target/gdb-runtime-group${group}.cmds" -gdb_log="target/gdb-runtime-group${group}.log" - -cat > "${gdb_cmds}" <<'EOF' -set confirm off -set pagination off -set print thread-events off -set print frame-arguments none -set print elements 0 -set print repeats 0 -set debuginfod enabled off -handle SIGSEGV stop print nopass -handle SIGABRT stop print nopass -handle SIGILL stop print nopass -run --nocapture --report-time --format ctrf --logfile target/ctrf.json ':tag:group__GROUP__' -if $_isvoid($_exitcode) && $_isvoid($_exitsignal) - echo \n=== Current Thread Backtrace ===\n - bt 40 - echo \n=== Thread List ===\n - info threads - echo \n=== Short Backtraces ===\n - thread apply all bt 8 - quit 1 -end -if !$_isvoid($_exitsignal) - quit 1 -end -EOF - -sed -i "s/__GROUP__/${group}/g" "${gdb_cmds}" - -set +e -timeout --signal=TERM 20m \ - gdb -q -batch -return-child-result -x "${gdb_cmds}" --args "${test_bin}" \ - > "${gdb_log}" 2>&1 -status=$? -set -e - -echo "=== gdb log (${gdb_log}) ===" -cat "${gdb_log}" -echo "=== end gdb log (exit code ${status}) ===" - -if [[ ${status} -eq 124 ]]; then - echo "gdb timed out after 20 minutes" >&2 -fi - -exit "${status}" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index effcbfa7..1309c8eb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -72,22 +72,8 @@ jobs: with: submodules: true - uses: ./.github/actions/setup - - name: Runtime tests under gdb (groups 1-2) - if: matrix.group == 1 || matrix.group == 2 - run: bash .github/scripts/run-runtime-group-under-gdb.sh ${{ matrix.group }} - name: Runtime tests (group ${{ matrix.group }}/8) - if: matrix.group != 1 && matrix.group != 2 run: cargo test --test runtime -- --nocapture --report-time --format ctrf --logfile target/ctrf.json ':tag:group${{ matrix.group }}' - - name: Upload gdb log - uses: actions/upload-artifact@v4 - if: always() && (matrix.group == 1 || matrix.group == 2) - with: - name: test-runtime-group-${{ matrix.group }}-gdb-log - path: | - target/gdb-runtime-group${{ matrix.group }}.log - target/gdb-runtime-group${{ matrix.group }}.cmds - target/ctrf-*.json - if-no-files-found: warn - name: Publish Test Report uses: ctrf-io/github-test-reporter@v1 if: always()