feat(run-report): recover the report of a run that ended without writing one #15973
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15973"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-11-05T04:59:46Z.
What
Recovers the report of a run that ended without writing one. Builds on the writer in #14235 and the counters in #15705, and contains both. Writing a report from
abort(),std::terminateand failed assertions is a separate follow-up PR.Recovery.
anyps5-report.<run id>.ckpt) and a lock file next to the report, written when the run starts and refreshed every five seconds by a worker thread. A normal end writes the report, removes the checkpoint and releases the lock.reports/<run id>/folders) for checkpoints whose lock is free, parses each one strictly (it must be exactly what the runtime would have written for that run, and every text value must pass the same filter) and writes a report from it:exit: killed,recovered: true,incomplete: true,stop.kind: other,stop.reason: unclean-unknown. That means the run ended without writing its report; it does not say what ended it. A checkpoint that fails the check is renamed.invalidand no report is made, never published in part.sceSystemServiceLoadExec) hands the report over before the process is replaced and reopens it if the replacement fails; the choice made with--aps5-reportsurvives the relaunch throughAPS5_REPORT. Linux, macOS and Windows code paths.Not here: stop kinds for an unsupported shader instruction and an unsupported image format (they need the shader diagnostics of the counters PR and come after it).
Tested
Linux (workstation).
run_report_testsrun directly on the final build (d5fcdf84db): 72 passed, 0 failed, 3 not run (the Windows-only detach test is reported as not run on Linux) (environment skips);ctest -R '^(run_report|guest_loadexec_fd_isolation|guest_system_relaunch|loadexec_arguments)': 5 of 5 passed.Each new behaviour was checked by removing it: with the recovery scan switched off
recovery,child-kill-and-recoverandfallback-recoveryfail; with the checkpoint lock made sharedfinish-recover-stress,removal-before-unlockandrecoveryfail; with the report never marked as handed overhandoff-outcomeandresumefail. The last fix is checked the same way: with the publish lock offresume-does-not-race-away-another-reportfails; with descriptor isolation offguest_loadexec_fd_isolationfails. Each passes with the code restored.Fix on review (round 2: a final write needs the acquired publish lock, so a timed-out run leaves its checkpoint to the next start (
finish-needs-publish-lock, red with the check removed); on Windows a detach without a finished report keeps the checkpoint (detach-without-finish-keeps-checkpoint, Windows only, not run)): the relaunch hand-off no longer leaks run-report descriptors into the replacement process (descriptor isolation),Resumetakes a publish lock so it cannot remove a report another run is publishing (the lock file is removed again while held, none is left behind), and the Windows checkpoint is kept on the paths that need it.Cost: report on adds 0.47 ms per run at start-up (1.47 ms off, 1.94 ms on, 300 runs x3, checkpoint written at start and removed at the end included); over a 12 s run the checkpoint thread adds 1.46 ms of cpu; one checkpoint write takes 0.029 ms. (Measured on
69ab87cf6f, which has the same recovery code; the review fix changes only the hand-off, the publish lock and tests.)Not run: Windows and macOS (the platform code, the
LoadExec.cpphand-off on all three systems, the Windows checkpoint cleanup), a relaunch of a real title, a real crash of a title.Things reviewers may question
LoadExec.cppchanges on three systems (the hand-off and the reopen when the replacement fails); none of the open PRs touch it today.SIGKILLor a power loss leave only the checkpoint (up to five seconds old), and no report is written if the game is never started again from that folder. The recovered report says only that the run ended without writing one. A run killed between writing its report and removing its checkpoint can leave a second, "killed" report beside the real one (not handled here).libSceVideoOut/src/VideoOutDriver.cpp(8); none touchLoadExec.cpporRunReport.cpp.privacy-sweep-everythingandkill-and-recoverrun with them.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T11:10:24Z.
Review: COMMENTED
Reviewed — no blocking findings
The recovery and relaunch changes appear sound in the inspected Linux paths; Windows and macOS behavior and several changed test and documentation files were not independently verified.
What I ran
Read the prepared diff and pinned repository sources at
e8be7be0f99500703663a4f81347ccbd8991f8e5. No build or tests were run;repo_read.pywas not run because its required plain shell command is unavailable here.Results
Findings
Blocking
None found in the inspected paths.
Non-blocking
None.
Not verified
The changed files listed as reviewed in the manifest were not all read. The inspected files were
core/libs/prx/libc/src/RunReport.cpp,core/libs/prx/libSceSystemService/LoadExec.cpp, andcore/libs/tests/RunReport.cpp(selected ranges). The prepared diff, description, commits, and manifest were read. The full contents ofcore/libs/prx/libSceSystemService/CMakeLists.txt,core/libs/prx/libSceSystemService/LoadExec.hpp,core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp,core/libs/prx/libc/include/RunReport.hpp,core/libs/tests/GuestSystemExit.cpp,.github/DISCUSSION_TEMPLATE/game-bring-up.yml,docs/dev/debt/libc.md,docs/user/USAGE.md,docs/user/run-report.md, andtools/tests/test_run_report_docs.pywere not read.files.jsonwas not listed in the prepared review folder, so exclusions by rule were not verified. The author reports Linux tests and performance measurements; these were not reproduced. Windows, macOS, real-title relaunch, and real-crash behavior were not verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:15:26Z.
Review: COMMENTED
Recovery can replace a complete report. Normal finalization writes the final JSON and then removes the checkpoint. If the run ends in between,
RecoverOnefinds the old checkpoint and writes a recovered report over the complete file. Please check for a completed report before replacing it. The branch also conflicts in the current run-report sources. All 14 documentation checks passed on Linux.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.