From 79bb026d7a21322e53faeddbb60c95ea935b75e7 Mon Sep 17 00:00:00 2001 From: Chris Laupama <42254688+chrislaupama@users.noreply.github.com> Date: Thu, 12 Nov 2026 02:29:32 +0000 Subject: [PATCH 1/2] Build the engine tests and benchmarks with GCC 15 The hosted Linux runner moved to Ubuntu 26.04, whose GCC 15 reports -Wnull-dereference (an error in CI) in three files: - Copies of file-scope default vectors written through operator[]: GCC can't see that a dynamically initialised global is non-empty. Use .at() for those writes in test_mod_routes.cpp and bench_devices.cpp. - memcpy from an empty vector's data() in bench_devices.cpp: skip the copy when there is nothing to copy (memcpy from null is undefined even for zero bytes). - sorted.back() on a possibly empty timing vector in bench_render.cpp: guard it the way run_render already does. --- engine/bench/bench_devices.cpp | 8 ++++---- engine/bench/bench_render.cpp | 8 ++++---- engine/tests/devices/test_mod_routes.cpp | 13 ++++++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/engine/bench/bench_devices.cpp b/engine/bench/bench_devices.cpp index 2ab20b5e..d456d738 100644 --- a/engine/bench/bench_devices.cpp +++ b/engine/bench/bench_devices.cpp @@ -56,7 +56,7 @@ std::vector blob_v2(const std::vector& v, const std::vector(v.size()), 0, 0, 0, static_cast(targets.size()), 0}; std::vector out(sizeof h + 4 * v.size() + sizeof(se_mod_route) * targets.size()); std::memcpy(out.data(), &h, sizeof h); - std::memcpy(out.data() + sizeof h, v.data(), 4 * v.size()); + if (!v.empty()) std::memcpy(out.data() + sizeof h, v.data(), 4 * v.size()); // memcpy from null is UB even for 0 bytes for (std::size_t i = 0; i < targets.size(); ++i) { se_mod_route r{targets[i], 0, SE_MOD_BUILTIN, 0, 0, 0, -0.25f, 0.25f, -60.f, 0.f, 1.f, 0.f}; std::memcpy(out.data() + sizeof h + 4 * v.size() + i * sizeof r, &r, sizeof r); @@ -145,7 +145,7 @@ std::vector blob(const std::vector& v, uint64_t sc = 0) { se_builtin_state h{SE_BUILTIN_STATE_MAGIC, static_cast(v.size()), sc}; std::vector out(sizeof h + 4 * v.size()); std::memcpy(out.data(), &h, sizeof h); - std::memcpy(out.data() + sizeof h, v.data(), 4 * v.size()); + if (!v.empty()) std::memcpy(out.data() + sizeof h, v.data(), 4 * v.size()); // memcpy from null is UB even for 0 bytes return out; } @@ -360,7 +360,7 @@ int main(int argc, char** argv) { const char* styles[] = {"Clean", "Opto", "Punch", "Smooth"}; for (int st = 0; st < 4; ++st) { std::vector v = kCompressor; - v[7] = static_cast(st); + v.at(7) = static_cast(st); char name[64]; std::snprintf(name, sizeof name, "compressor (%s)", styles[st]); row(name, bench_kernel("compressor", v, blocks, 0)); @@ -409,7 +409,7 @@ int main(int argc, char** argv) { const char* models[] = {"Clean", "Vari-Mu", "Bus VCA", "FET", "Opto", "RMS VCA"}; for (int m = 0; m < 6; ++m) { std::vector v = kCharacter; - v[0] = static_cast(m); + v.at(0) = static_cast(m); char name[64]; std::snprintf(name, sizeof name, "character-compressor (%s)", models[m]); row(name, bench_kernel("character-compressor", v, blocks, 0)); diff --git a/engine/bench/bench_render.cpp b/engine/bench/bench_render.cpp index 72bef290..a6e2dece 100644 --- a/engine/bench/bench_render.cpp +++ b/engine/bench/bench_render.cpp @@ -394,7 +394,7 @@ Result run_preview_notes(uint32_t tracks, uint32_t blocks, int mode) { Result r{}; r.us_per_block_avg = wall_us / blocks; r.us_per_block_p99 = sorted[static_cast(0.99 * (blocks - 1))]; - r.us_per_block_max = sorted.back(); + r.us_per_block_max = sorted.empty() ? 0.0 : sorted.back(); r.rt_ratio = static_cast(blocks) * kBlock / kRate * 1e6 / wall_us; return r; } @@ -459,7 +459,7 @@ Result run_midi(uint32_t tracks, uint32_t blocks, const se_synth_params* params) Result r{}; r.us_per_block_avg = wall_us / blocks; r.us_per_block_p99 = sorted[static_cast(0.99 * (blocks - 1))]; - r.us_per_block_max = sorted.back(); + r.us_per_block_max = sorted.empty() ? 0.0 : sorted.back(); r.rt_ratio = static_cast(blocks) * kBlock / kRate * 1e6 / wall_us; return r; } @@ -527,7 +527,7 @@ Result run_midi_input(uint32_t tracks, uint32_t blocks, int mode) { Result r{}; r.us_per_block_avg = wall_us / blocks; r.us_per_block_p99 = sorted[static_cast(0.99 * (blocks - 1))]; - r.us_per_block_max = sorted.back(); + r.us_per_block_max = sorted.empty() ? 0.0 : sorted.back(); r.rt_ratio = static_cast(blocks) * kBlock / kRate * 1e6 / wall_us; return r; } @@ -668,7 +668,7 @@ Result run_input(uint32_t tracks, uint32_t blocks, bool record) { Result r{}; r.us_per_block_avg = wall_us / blocks; r.us_per_block_p99 = sorted[static_cast(0.99 * (blocks - 1))]; - r.us_per_block_max = sorted.back(); + r.us_per_block_max = sorted.empty() ? 0.0 : sorted.back(); r.rt_ratio = static_cast(blocks) * kBlock / kRate * 1e6 / wall_us; return r; } diff --git a/engine/tests/devices/test_mod_routes.cpp b/engine/tests/devices/test_mod_routes.cpp index fd61a68e..b47fd732 100644 --- a/engine/tests/devices/test_mod_routes.cpp +++ b/engine/tests/devices/test_mod_routes.cpp @@ -73,8 +73,11 @@ TEST_CASE(lfo_shapes_follow_the_spec) { TEST_CASE(lfo_free_rate_and_synced_clock) { // Free, 1 Hz sine: the wave peaks at 0.25 s and bottoms out at 0.75 s. + // .at() on copies of the file-scope defaults: GCC 15 can't see that a + // dynamically initialised global vector is non-empty and flags [] writes + // as null dereferences (-Wnull-dereference, an error in CI). std::vector v = kLfo; - v[1] = 0.f; + v.at(1) = 0.f; DeviceRig rig("lfo", v); auto p = lfo_points(rig, 48000, false); CHECK_NEAR(p[0], 0.5, 1e-4); @@ -156,11 +159,11 @@ TEST_CASE(lfo_moves_a_builtin_parameter_in_the_engine) { EngineHandle e(48000, 256); const uint64_t a = load_asset(e, {sine(48000, 400.0, 48000.0, 0.1), sine(48000, 400.0, 48000.0, 0.1)}); std::vector comp = kComp; - comp[0] = 0.f; // threshold at 0 dB, ratio 1: no compression - comp[1] = 1.f; + comp.at(0) = 0.f; // threshold at 0 dB, ratio 1: no compression (.at(): see above) + comp.at(1) = 1.f; std::vector lfo = kLfo; - lfo[0] = 4.f; // square - lfo[1] = 0.f; // free, 1 Hz + lfo.at(0) = 4.f; // square + lfo.at(1) = 0.f; // free, 1 Hz uint64_t id = 10; // fresh instances per run: a free LFO starts its cycle when created const auto run = [&](bool lfo_on, float depth) { DeviceSession s; From 3add074e16f7cca336aec6c3ea4eb7e8398f7b2e Mon Sep 17 00:00:00 2001 From: Chris Laupama <42254688+chrislaupama@users.noreply.github.com> Date: Thu, 12 Nov 2026 03:48:53 +0000 Subject: [PATCH 2/2] Exit with the real exit code on Windows After any run that opened the window, a normal process exit on Windows reported 0x87A instead of 0: the code is replaced after main returns, while the process unloads its DLLs (same with or without audio, a screenshot or presented frames; an exit before the window exists is 0). The app now ends its process directly once run() has returned, and CI and the release smoke test check the exit code on Windows too. --- .github/workflows/ci.yml | 8 +++---- .github/workflows/release.yml | 1 + crates/dstudio-app/src/main.rs | 39 ++++++++++++++++++++++++++++++---- engine/README.md | 10 ++++++--- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b08189ec..da967ccf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -466,10 +466,8 @@ jobs: grep -h -E "^self-test" "$RUNNER_TEMP/selftest.log" "$RUNNER_TEMP/selftest-audio.log" if [ "$shot_status" -ne 0 ] || [ ! -s app-linux.png ]; then echo "::error title=Screenshot failed (Linux)::exit status $shot_status"; exit 1; fi [ "$plain_status" -eq 0 ] && [ "$audio_status" -eq 0 ] - # Windows exits with code 0x87A after a run that passed (not yet - # explained, see engine/README.md), so the exit code is printed but not - # checked; a missing screenshot or self-test summary, or a failed check, - # fails the step. + # A non-zero exit code, a missing screenshot or self-test summary, or a + # failed check fails the step. - name: App — screenshot (Windows, WARP) if: runner.os == 'Windows' && steps.changes.outputs.run == 'true' timeout-minutes: 5 @@ -484,6 +482,7 @@ jobs: Get-Content shot-windows-stderr.txt "screenshot run exit code: 0x{0:X8}" -f $p.ExitCode if (-not (Test-Path app-windows.png)) { throw "no screenshot" } + if ($p.ExitCode -ne 0) { throw "the app exited with 0x{0:X8}" -f $p.ExitCode } # The full self-test under WARP takes about 30 minutes (the software # renderer is capped at two frames in flight so it no longer runs out of # memory), so pull requests skip it unless they carry the @@ -511,6 +510,7 @@ jobs: if (-not $line) { Get-Content selftest-windows-stderr.txt -Tail 30; throw "no self-test summary" } $line.Value if ($line.Groups[1].Value -ne $line.Groups[2].Value) { throw "self-test failures" } + if ($p.ExitCode -ne 0) { throw "the self-test passed but the app exited with 0x{0:X8}" -f $p.ExitCode } - name: Upload app screenshots and self-test logs if: steps.changes.outputs.run == 'true' && !cancelled() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b187e3bb..8244416f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -316,6 +316,7 @@ jobs: $p = Start-Process -FilePath (Join-Path $dir 'device-studio.exe') -ArgumentList '--state', 'reference-default', '--screenshot', $shot -NoNewWindow -Wait -PassThru "exit code: 0x{0:X8}" -f $p.ExitCode if (-not (Test-Path $shot)) { throw "the installed app did not render" } + if ($p.ExitCode -ne 0) { throw "the installed app exited with 0x{0:X8}" -f $p.ExitCode } - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: package-windows diff --git a/crates/dstudio-app/src/main.rs b/crates/dstudio-app/src/main.rs index 5d072a82..e24aa196 100644 --- a/crates/dstudio-app/src/main.rs +++ b/crates/dstudio-app/src/main.rs @@ -945,10 +945,41 @@ fn synth_test_state(device: dstudio_core::DeviceId) -> dstudio_core::Command { } fn main() { - if let Err(e) = run() { - eprintln!("device-studio: {e}"); - std::process::exit(1); - } + let code = match run() { + Ok(()) => 0, + Err(e) => { + eprintln!("device-studio: {e}"); + 1 + } + }; + exit_now(code); +} + +/// End the process with `code` once `run` has returned and everything it owns is dropped. +/// +/// On Windows a normal exit (returning from `main`, or `std::process::exit`) reported +/// 0x87A instead of our code after any run that had opened the window: something in the +/// graphics stack ends the process with its own code while its DLLs unload, with the wgpu +/// device still alive in Slint's thread-local backend. Nothing of ours is left to run at +/// that point (the project, settings and engine are closed inside `run`), so the process +/// is ended directly, which skips DLL unloading and gives the caller the real result. +#[cfg(windows)] +fn exit_now(code: i32) -> ! { + use std::io::Write; + unsafe extern "system" { + fn GetCurrentProcess() -> *mut std::ffi::c_void; + fn TerminateProcess(process: *mut std::ffi::c_void, exit_code: u32) -> i32; + } + let _ = std::io::stdout().flush(); + let _ = std::io::stderr().flush(); + // SAFETY: both calls take no pointers from us; the pseudo-handle is always valid. + unsafe { TerminateProcess(GetCurrentProcess(), code as u32) }; + std::process::exit(code) +} + +#[cfg(not(windows))] +fn exit_now(code: i32) -> ! { + std::process::exit(code) } /// AppKit adds Start Dictation, Emoji & Symbols and Enter Full Screen to any Edit and View diff --git a/engine/README.md b/engine/README.md index b6fa95ba..6c825ad7 100644 --- a/engine/README.md +++ b/engine/README.md @@ -136,9 +136,13 @@ without a GPU or audio device: on Linux under Xvfb with Mesa lavapipe (software are reported as skipped off macOS), as a required step; on Windows with WARP (DX12 software adapter) the same, also failing the job when a check fails (the full self-test runs on main, nightly and labelled pull requests that change -the app; see docs/building.md): the screenshot renders and the self-test passes, but the -process exits with code 0x87A after the run (not yet explained; macOS/Linux -exit 0), so CI prints that exit code and checks the summary line instead. +the app; see docs/building.md): the screenshot renders, the self-test passes and the +exit code is checked on all three systems. On Windows the app ends its process directly +once `run` has returned (`exit_now` in `crates/dstudio-app/src/main.rs`): with a normal +exit, any run that had opened the window reported 0x87A instead of our code. The code is +set after `main` returns, while the process unloads its DLLs, with or without audio, a +screenshot or presented frames; a run that exits before the window exists returns 0. +Seen with WARP on the hosted runner; not yet checked on a real GPU. Debug builds of the app abort at exit on every OS (pre-existing: wgpu-core's debug-only lock tracing runs in a TLS destructor when Slint's thread-local backend drops the wgpu queue), so CI uses a release build. Screenshots and logs are uploaded as artifacts.