Repository navigation
fix(libc): write the run report when the run ends in std::terminate - #16757
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
67d6e9e to
de2eeea
Compare
|
Results, each case 3 times:
The failure on the test commit is the one the case is there for. The child ends through The Windows runs used the earlier head A title, MXGP 2026 (PPSA30839), on release libs built from this change: it stops 7 s in on AI-assisted: yes (Claude Code) |
gabichuuuuu
left a comment
There was a problem hiding this comment.
Read de2eeea8f7 against main.
The terminate path now takes the stderr stream lock. Runtime.cpp:19-20 says terminate paths write raw because another, possibly suspended, thread may hold the CRT stream lock. InvokeTerminate (Runtime.cpp:94-98) now runs the report's Finish first, and Finish prints with std::fprintf(stderr, …) (RunReport.cpp:1599-1604). If another thread holds the stderr lock and isn't running, for example one suspended by the Windows sceKernelRaiseException path, the terminating thread blocks there and the run hangs instead of aborting. Not reproduced; skipping those lines when exit is Abort, or printing them with the raw writer, removes it. The collector's own locks are fine: mutex is only held to flip state, the tables use try_lock_for, and a second terminate waits at most 3 s (:1571-1573) and returns.
A terminate handler that exits is reported as abort. The report is finished before the handler runs, so a title handler that calls exit(3) reaches LibcRunReportFinishExit_nid_no_patch with the report already done: it says abort with a null exit code while the process exits with 3. Writing it first only for DefaultTerminate / std::abort, and otherwise after the handler returns, keeps both cases right.
User docs. docs/user/run-report.md:15 and docs/user/USAGE.md:506 still say "A run that is killed, crashes or aborts writes no report", run-report.md:46 lists only guest-exit, and tools/tests/test_run_report_docs.py:49-52 pins the old USAGE sentence. Only the debt entry was updated.
Stop kind. The schema already has kind: missing-function with a source (docs/run-report-fixtures/stop-missing-function.json), and NotImplementedAt_nid_no_patch knows the file and line, yet the motivating case is reported as other with a null source.
Template. GPUs tested should read n/a for a change outside AGC, the shader recompiler and VideoOut.
CI. The new child-process case is #ifndef _WIN32 and the Linux job doesn't run on pull requests, so it has only run on the author's machine.
Not run here; this is from reading the code.
AI-assisted: yes.
…ction, run a game's handler first Review on boykopovar#16757 (gabichuuuuu): - Finish prints nothing on an abort exit. The terminate path writes raw because another, possibly suspended, thread may hold the stderr stream lock, and the report's fprintf would block on it. - A terminate that a function that is not implemented threw is reported as kind missing-function with that function's library, name and source (the last one noted on the thread), as the schema fixture shows. Other exceptions stay kind other with their text. - With the runtime's own handler (DefaultTerminate, std::abort) the report is written before it runs. With a game's handler it is written after the handler returns, so a handler that exits writes its own clean report with the exit code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @gabichuuuuu, all of it holds. The fixes are three commits on top:
The Linux (test commit AI-assisted: yes (Claude Code) |
|
Results for the review fixes, 3 runs each:
On the test commit, both new cases fail as intended:
AI-assisted: yes (Claude Code) |
|
Ran So Windows doesn't cover the fix. AI-assisted: yes. |
|
Right, thanks @gabichuuuuu: my Windows rows only show that nothing else in AI-assisted: yes (Claude Code) |
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
|
Thanks @JJenkx. One note on what that run covers: the child-process cases ( AI-assisted: yes (Claude Code) |
A child run that leaves an unimplemented function's exception uncaught must end through abort and still write anyps5-report.json, with exit abort, reason runtime-stop, the exception's text as the stop message and the function in the missing-function table. On main it writes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LibcException::InvokeTerminate now finishes the run report before the terminate handler runs: exit abort, reason runtime-stop, and the caught exception's what() as the stop message. Before, only exit, _exit and a returning entry wrote the report, so a title that stopped on a function that is not implemented (the throw ends in std::terminate) left none. The report format already had the abort exit and the runtime-stop reason; nothing produced them. DefaultTerminate's what() lookup moves into CaughtWhat so both use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nate handler that exits The uncaught unimplemented function's report must carry kind missing-function and the "Called ..., which is not implemented." message the schema fixture uses. A child whose own terminate handler calls exit(3) must exit with 3 and leave a clean report with exit code 3, not an abort one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ction, run a game's handler first Review on boykopovar#16757 (gabichuuuuu): - Finish prints nothing on an abort exit. The terminate path writes raw because another, possibly suspended, thread may hold the stderr stream lock, and the report's fprintf would block on it. - A terminate that a function that is not implemented threw is reported as kind missing-function with that function's library, name and source (the last one noted on the thread), as the schema fixture shows. Other exceptions stay kind other with their text. - With the runtime's own handler (DefaultTerminate, std::abort) the report is written before it runs. With a game's handler it is written after the handler returns, so a handler that exits writes its own clean report with the exit code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
954b00b to
e5a2cfb
Compare
|
@milescoviello the debt file now has two Run report bullets at e5a2cfb. The merge of main kept main's old bullet (line 374, which says a run that crashes or aborts writes no report and does not mention std::terminate) next to your new bullet at line 377, so the two contradict each other. Please delete the old bullet and keep the new one. The rest of the head matches the version that was reviewed. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e5a2cfb to
8e20e9b
Compare
|
Thanks @oneandonlydean — fixed in AI-assisted: yes (Claude Code) |
|
@milescoviello one thing from this on Windows: |
#16757 added 'thread_local MissingFunctionStop missing;' in RunReport.cpp lastMissing(). On Windows a thread_local destructor in a module runs after emulated TLS has freed the object, so prx_thread_local_destructors fails on main. Use HostThreadLocal (fiber-local storage on Windows, thread_local elsewhere), like Radix64.cpp.
|
Thanks @oneandonlydean, and for the fix in #19347. Understood — I'll use |
What
A run that ends in
std::terminatenow writes its run report, with exitabortand reasonruntime-stop. When a function that is not implemented threw, the stop ismissing-functionwith that function's source and the schema fixture's "Called …, which is not implemented." message; otherwise it isotherwith the exception's text. With the runtime's own terminate handler the report is written before it runs; a game's own handler runs first, so one that exits writes its own clean report.LibcException::InvokeTerminate(libc's exception runtime, which the host libraries and the title both throw through) finishes the report before it calls the terminate handler, through a newLibcRunReportTerminate_nid_no_patch. The terminate handler then runs as before, so theterminate called after throwing ...line and the abort are unchanged.Before, only
exit,_exitand an entry that returns wrote the report, anddocs/dev/debt/libc.mdsaid so ("A run that crashes, aborts or is killed writes no report"). The report format already had theabortexit and theruntime-stopreason ("The runtime stopped the run on an error it reported."), but nothing produced them.DefaultTerminate's lookup of the caught exception'swhat()moves intoCaughtWhat, so the report and the default handler read it the same way. On Windows its guestwhat()call now spells the calling convention withAPS5_VABI, which is the same__attribute__((sysv_abi))there.Why
A function that is not implemented throws (
NotImplementedAt_nid_no_patch), and when nothing catches it the throw ends instd::terminate. That is how most titles stop today, and none of those runs wrote a report, so nothing could be uploaded for them. Onmain090f57166atonight:sceHttp2SendRequestAsync not implemented, with noanyps5-report.json.The missing-function table was already filled in before the throw (
NoteMissingFunction). With this change it reaches the report.Test
The first commit adds
child-uncaught-missing-functiontorun_report(core/libs/tests/RunReport.cpp), in the same child-process harness aschild-missing-function. The child callsNotImplemented_nid_no_patch("sceNpUncaught")on a thread of its own that catches nothing, the way a title's thread does. The test then requires that:abort;"exit": "abort","reason": "runtime-stop","kind": "other"and"message": "sceNpUncaught not implemented";sceNpUncaughtonce.On the test commit the child aborts without writing a report, so the test fails there.
The debt entry now describes the terminate path, and still lists what writes no report: a crash on a signal, a direct
abortand a killed run. It also notes that the child-process tests are built on Linux and macOS only.Tested
anyps5-report.jsonwith"exit": "abort", stop{"kind": "other", "reason": "runtime-stop", "message": "sceHttp2SendRequestAsync not implemented"}and stagepresents. Onmainthe same run leaves no report._WIN32CaughtWhatpath;run_report,guest_sce_v2_exceptionsandexception_personalitypass 3 of 3 on each;exception_runtimeandexception_c_cleanupare not built on Windows;#ifndef _WIN32, so the new case does not run there.run_reportfails 3 of 3 on the test commit807251284d(... lacks "exit": "abort": the child aborts without a report) and passes 3 of 3 at the headde2eeea8f7;exception_runtime,exception_c_cleanup,exception_personalityandguest_sce_v2_exceptionspass on both. (A first run had the child throw inside the harness's owntryinmain(); the case now throws on a thread of its own, as a title's thread does.)-fsyntax-onlywith the build's flags andtools/check_conventions.py --base upstream/mainpass.Overlap: #14298 reports fatal host signals on Linux in the log file, and #16591 adds an include to
RunReport.cpp. Neither touches the terminate path, and both merge cleanly with this.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)mainand leave no report)🤖 Generated with Claude Code