From b04490aff85ee40b27216c25b7ad31b813c4fa36 Mon Sep 17 00:00:00 2001 From: nv-slang-bot <174632915+nv-slang-bot[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 05:34:43 +0000 Subject: [PATCH] tests: arm Crashpad in sgl_tests so teardown faults produce a minidump The sgl_tests C++ harness exits nonzero after a green doctest summary when a fault occurs during post-run teardown (#1062). Crashpad is compiled into the CI binary and an upload step is configured, but the handler was only armed on the Python side; the C++ main never called start_handler(), so a teardown fault wrote no minidump and the log showed only a bare 'exit 1'. Arm Crashpad after sgl::testing::static_init() and before context.run(), guarded on SGL_HAS_CRASHPAD, wrapped in try/catch so a failure to arm never takes down the run. Pass an explicit '.crashpad' database directory to match the path CI archives and the Python harness uses; the default sits next to the binary where the upload step does not look. Also fix the crashpad upload in the build-and-test-with-slang composite action (which services the cross-repo 'SlangPy Tests' lane): archive the whole .crashpad/ database instead of just reports/ (POSIX Crashpad writes to pending/, and the Python copy step is skipped when the C++ step itself crashes), and set include-hidden-files so upload-artifact does not silently skip the dot-directory. Diagnostics only: the exit-code path is untouched, so real test failures and mid-test crashes still red the job. --- .../actions/build-and-test-with-slang/action.yml | 8 +++++++- tests/sgl/sgl_tests.cpp | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/actions/build-and-test-with-slang/action.yml b/.github/actions/build-and-test-with-slang/action.yml index bab81064c..287b0d3a2 100644 --- a/.github/actions/build-and-test-with-slang/action.yml +++ b/.github/actions/build-and-test-with-slang/action.yml @@ -187,12 +187,18 @@ runs: run: python tools/ci.py test-examples -p # Upload Crashpad Reports + # Upload the whole database rather than just reports/: Windows writes minidumps directly to + # reports/, but POSIX Crashpad leaves them in pending/ until the Python harness copies them + # over, which never happens when the C++ sgl_tests step itself crashes (#1062). - name: Upload Crashpad Reports if: always() && contains(inputs.flags, 'crashpad') uses: actions/upload-artifact@v7 with: name: crash-reports-${{ inputs.os }}-${{ inputs.platform }}-${{ inputs.compiler }}-${{ inputs.config }} - path: .crashpad/reports/ + path: .crashpad/ + # .crashpad is a dot-directory; upload-artifact treats its contents as hidden and skips + # them by default, which if-no-files-found:ignore would silently mask. + include-hidden-files: true if-no-files-found: ignore # Generate Coverage Report diff --git a/tests/sgl/sgl_tests.cpp b/tests/sgl/sgl_tests.cpp index bdab52d31..691093f84 100644 --- a/tests/sgl/sgl_tests.cpp +++ b/tests/sgl/sgl_tests.cpp @@ -4,9 +4,11 @@ #include "sgl/sgl.h" #include "sgl/device/device.h" #include "sgl/device/agility_sdk.h" +#include "sgl/core/config.h" #include "sgl/core/object.h" #include "sgl/core/logger.h" #include "sgl/core/error.h" +#include "sgl/utils/crashpad.h" #define DOCTEST_CONFIG_IMPLEMENT #include @@ -50,6 +52,17 @@ int main(int argc, char** argv) { sgl::testing::static_init(); +#if SGL_HAS_CRASHPAD + // Capture teardown faults (#1062) as a minidump. The database must be the `.crashpad` + // directory CI archives, not the default beside the binary. Arming is best-effort: + // these diagnostics must never affect the test result. + try { + sgl::crashpad::start_handler({}, ".crashpad"); + } catch (const std::exception& e) { + sgl::log_warn("Failed to start Crashpad handler: {}", e.what()); + } +#endif + doctest::Context context(argc, argv); context.setOption("--reporters", "sgl");