fix(tests): stop a failed recorder test without unwinding through objects its open batch still records #10684

Merged
fma-rc merged 6 commits from upstream-pr/10684 into main 2026-10-26 21:31:16 +00:00
fma-rc commented 2026-10-24 17:41:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-24T17:41:24Z.


What

When a check fails in agc_driver_recorder_tests, the message never reaches the log on lavapipe: the test segfaults. On RADV it prints [gpu] recorder teardown: AGC graphics: vkQueueSubmit recorder: Vulkan result -4 first.

main() wrapped every test in try { ... } catch (const std::exception&). A failed Require unwinds the test function, which destroys its locals (TextureDetiler, SampleProgram, textures) while the recorder's open batch still records their pipelines and descriptor sets: texture uploads stay in the open batch by design. Then main()'s Recorder is destroyed, ~Recorder runs Sync(), and submits that batch. The driver's own teardown order is right (the device resets its recorder before its detiler), so this is only the test binary.

This drops the outer catch and installs a terminate handler through libc's set_terminate export, as tests/Graphics.cpp does. An uncaught exception reaches it before any unwinding, so nothing is destroyed or submitted. The handler flushes stdout, prints the exception's message (or a line saying there was none, or that it was not a std::exception), and ends through LibcTerminate_nid_no_patch(1), the same exit the Windows test wrapper uses. Exit code 1 and the message are unchanged; skip paths still return 77. The rest of main() keeps its indentation inside a plain block, so the change stays off the lines other open PRs edit there.

I found it with a texture upload test whose red run crashed on lavapipe instead of failing with its message. Moving the 40 test-local detilers into the shared test device would not cover it: 5 of those tests build their detiler from a context they changed, and other locals than the detiler can be in the open batch.

Tested

New test agc_recorder_failed_check: one texture upload into the open batch, then a failing check. It passes when the message is printed and recorder teardown is not.

without the fix with the fix
RADV, Radeon 680M, Mesa 26.2.4 fails: recorder teardown ... Vulkan result -4 pass
lavapipe segfault pass
NVIDIA RTX 5080, 615.78.08 pass (the driver accepts the batch) pass

ctest -R '^agc_recorder' passes on RADV and lavapipe with the fix. Full ctest on RADV shows no failure that the merge base lacks (agc_driver_tessellation fails on both). Windows (MinGW GCC): build, ctest, tools tests and conventions show no failure that the merge base lacks; the VM has no GPU, so agc_recorder_failed_check skips there. Arch Linux.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA RTX 5080 (driver 615.78.08), AMD Radeon 680M (RADV, Mesa 26.2.4), lavapipe, all Arch Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4997644187 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10684). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-24T17:41:24Z. --- ### What When a check fails in `agc_driver_recorder_tests`, the message never reaches the log on lavapipe: the test segfaults. On RADV it prints `[gpu] recorder teardown: AGC graphics: vkQueueSubmit recorder: Vulkan result -4` first. `main()` wrapped every test in `try { ... } catch (const std::exception&)`. A failed `Require` unwinds the test function, which destroys its locals (`TextureDetiler`, `SampleProgram`, textures) while the recorder's open batch still records their pipelines and descriptor sets: texture uploads stay in the open batch by design. Then `main()`'s `Recorder` is destroyed, `~Recorder` runs `Sync()`, and submits that batch. The driver's own teardown order is right (the device resets its recorder before its detiler), so this is only the test binary. This drops the outer catch and installs a terminate handler through libc's `set_terminate` export, as `tests/Graphics.cpp` does. An uncaught exception reaches it before any unwinding, so nothing is destroyed or submitted. The handler flushes stdout, prints the exception's message (or a line saying there was none, or that it was not a `std::exception`), and ends through `LibcTerminate_nid_no_patch(1)`, the same exit the Windows test wrapper uses. Exit code 1 and the message are unchanged; skip paths still return 77. The rest of `main()` keeps its indentation inside a plain block, so the change stays off the lines other open PRs edit there. I found it with a texture upload test whose red run crashed on lavapipe instead of failing with its message. Moving the 40 test-local detilers into the shared test device would not cover it: 5 of those tests build their detiler from a context they changed, and other locals than the detiler can be in the open batch. ### Tested New test `agc_recorder_failed_check`: one texture upload into the open batch, then a failing check. It passes when the message is printed and `recorder teardown` is not. | | without the fix | with the fix | |---|---|---| | RADV, Radeon 680M, Mesa 26.2.4 | fails: `recorder teardown ... Vulkan result -4` | pass | | lavapipe | segfault | pass | | NVIDIA RTX 5080, 615.78.08 | pass (the driver accepts the batch) | pass | `ctest -R '^agc_recorder'` passes on RADV and lavapipe with the fix. Full ctest on RADV shows no failure that the merge base lacks (`agc_driver_tessellation` fails on both). Windows (MinGW GCC): build, ctest, tools tests and conventions show no failure that the merge base lacks; the VM has no GPU, so `agc_recorder_failed_check` skips there. Arch Linux. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA RTX 5080 (driver 615.78.08), AMD Radeon 680M (RADV, Mesa 26.2.4), lavapipe, all Arch Linux - [x] AI-assisted: yes
MarcZX10 commented 2026-10-24 19:22:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T19:22:19Z.

Review: APPROVED


Reviewed agc_recorder_failed_check at head 18d170c1636d2c9d923fe3adce8da3564f3bcc1f. The termination-handler change is narrowly scoped and matches the test's lifetime hazard: the failure path exits without unwinding objects referenced by the recorder's open batch, and the regression check verifies the failure message while ensuring recorder teardown does not run. The target agc_driver_recorder_tests built successfully locally. I also ran ctest --test-dir /tmp/anyps5-10694-build -R '^agc_recorder_failed_check$' --output-on-failure; it aborted during host CPU feature validation (this Xeon lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA), before reaching the regression assertion. Hosted product tests are skipped by repository policy; the PR reports successful runs on RADV/lavapipe/NVIDIA and Windows. Intake, conventions and labels checks are green, and the PR is mergeable.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639594375 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10684#pullrequestreview-5639594375). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T19:22:19Z. **Review:** APPROVED --- Reviewed `agc_recorder_failed_check` at head `18d170c1636d2c9d923fe3adce8da3564f3bcc1f`. The termination-handler change is narrowly scoped and matches the test's lifetime hazard: the failure path exits without unwinding objects referenced by the recorder's open batch, and the regression check verifies the failure message while ensuring recorder teardown does not run. The target `agc_driver_recorder_tests` built successfully locally. I also ran `ctest --test-dir /tmp/anyps5-10694-build -R '^agc_recorder_failed_check$' --output-on-failure`; it aborted during host CPU feature validation (this Xeon lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA), before reaching the regression assertion. Hosted product tests are skipped by repository policy; the PR reports successful runs on RADV/lavapipe/NVIDIA and Windows. Intake, conventions and labels checks are green, and the PR is mergeable.
MarcZX10 commented 2026-10-24 20:24:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:24:09Z.

Review: APPROVED


Reviewed the functional diff at 18d170c163 (the large remainder of Recorder.cpp is indentation-only). The terminate handler prints the active exception and exits without unwinding test-local objects referenced by an open recorder batch; agc_recorder_failed_check exercises a texture upload followed by a failed Require and rejects the old teardown failure. The author reports the regression passing on RADV and lavapipe, with the prior code failing on both, plus no newly introduced full-suite Windows failures. Hosted eligibility, conventions, labels and report pass; product jobs were skipped by repository policy.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639813595 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10684#pullrequestreview-5639813595). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T20:24:09Z. **Review:** APPROVED --- Reviewed the functional diff at 18d170c1636d2c9d923fe3adce8da3564f3bcc1f (the large remainder of Recorder.cpp is indentation-only). The terminate handler prints the active exception and exits without unwinding test-local objects referenced by an open recorder batch; `agc_recorder_failed_check` exercises a texture upload followed by a failed Require and rejects the old teardown failure. The author reports the regression passing on RADV and lavapipe, with the prior code failing on both, plus no newly introduced full-suite Windows failures. Hosted eligibility, conventions, labels and report pass; product jobs were skipped by repository policy.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!10684
No description provided.