Repository navigation
feat(run-report): write the run report when a game ends - #14235
Conversation
A run of a converted game writes anyps5-report.json when it ends through exit or _exit (or the entry returns): the build revision, the game, the machine, and the unimplemented functions that were called. It is on by default; --aps5-report=off or APS5_REPORT=0 turns it off. Every text value is filtered for user names, host names, addresses and account numbers. Runs that crash, abort or are killed write no report yet; milestones, frame counts and shader and image lists are marked as not collected.
|
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.
|
The schema test starts run_report_tests from Python: the libc folder was not on PATH, so the executable failed to load (0xc0000135), and the --dump mode that writes the sample reports existed only on POSIX, so there was nothing to validate.
# Conflicts: # docs/dev/debt/libc.md
|
Linux title validation of head
Normal Linux exit only; no Windows/macOS, crash/kill recovery, audio, completion or performance claim. Exact source integration · Report, tests, patch and reviewed captures. Archive SHA256 |
MarcZX10
left a comment
There was a problem hiding this comment.
Changes requested: this PR breaks the Emscripten portability build with a link error
The Emscripten library-portability job fails on this head at link time, and the cause is this PR. It changes NotImplemented_nid_no_patch in core/libs/prx/libc/include/General.hpp into a macro that calls a new function, NotImplementedAt_nid_no_patch(name, __FILE__, __LINE__). The Emscripten test emscripten_module_unwind compiles libkernel/Module/src/Module.cpp, which uses that macro, and it defines only NotImplemented_nid_no_patch (core/libs/tests/emscripten/EmscriptenModuleUnwind.cpp, line 18). The new symbol is not defined in that link, so it fails.
What I ran
- Head
a6bb84be17d6c58584ce6bdbfeb603cf462db496; base90cc8d57a5c98bc1ae1237c94516c025031c7c58. The PR touches the libc run-report files,General.hpp,General.cpp, the libc and root CMake files, a schema workflow and the docs (the full list was not counted). - Read the
General.hppchange at the head (lines 15-17: the new declaration and the macro) and the base (line 15: the function). Read the new definition inGeneral.cpp(around lines 1020-1030). - Read the
emscripten_module_unwind_teststarget incore/libs/tests/emscripten/CMakeLists.txt: it compilesEmscriptenModuleUnwind.cpp,libkernel/Module/src/Module.cppandlibSceSysmodule/Export.cpp. It does not compileGeneral.cpp. - Read
EmscriptenModuleUnwind.cppat the base and at the head: both defineNotImplemented_nid_no_patch(const char*)at line 18; neither definesNotImplementedAt_nid_no_patch. - Hosted: the
library-portabilityjob fails withwasm-ld: error: … undefined symbol: NotImplementedAt_nid_no_patchinemscripten_module_unwind_tests.dir/…/Module.cpp.o. NoNotImplementedAtappears anywhere in the base. - Hosted, other jobs: conventions, eligibility, labels, report, schema, the three macOS and Ubuntu and Windows relinkers, relinker-asan and the write-watch jobs passed;
windowswas cancelled; linux skipped. - Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed (no declared dependencies, no errors). ABI audit passed with warnings: 16 findings, not read in detail.
- No MarcZX10 review at this head.
Results
| Check | Result | Note |
|---|---|---|
| Diff check | passed | |
| Conventions and PR template | passed | conventions check from the main checkout |
| Mergeability and dependencies | passed | stack check passed; no declared dependencies; no errors |
Emscripten library-portability (hosted) |
failed | link error: undefined symbol: NotImplementedAt_nid_no_patch in emscripten_module_unwind_tests; caused by the new macro in General.hpp |
NotImplementedAt_nid_no_patch defined for the Emscripten test |
no | the test defines only NotImplemented_nid_no_patch |
| Windows CTest | cancelled | no result for this head |
| Relinkers and relinker-asan (hosted) | passed | all succeeded |
| ABI audit (main-checkout tool) | passed with warnings | 16 findings, not read in detail |
| Negative controls | not run | no local build |
| Hosted CI | failed | library-portability failed; windows cancelled |
Read-only check output
Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: passed with warnings (16). Stack check: passed, no errors. Hosted: gh api repos/boykopovar/AnyPS5/commits/a6bb84be17d6c58584ce6bdbfeb603cf462db496/check-runs, and the library-portability job log.
Negative control
Not run here. A negative control needs a local build, and code from this head is not run here.
Findings
Blocking
- The Emscripten
library-portabilityjob fails at link time on this head. The new macro inGeneral.hpp(lines 16-17) makesModule.cppcallNotImplementedAt_nid_no_patch, whichcore/libs/tests/emscripten/EmscriptenModuleUnwind.cppdoes not define. Fix one of these: defineNotImplementedAt_nid_no_patchin that test with the new signature, or keep the call sites linking as they did before. Then rerun thelibrary-portabilityjob.
Non-blocking
- The ABI audit reports 16 findings that were not read in detail.
Sources
- Header: https://github.com/boykopovar/AnyPS5/blob/a6bb84be17d6c58584ce6bdbfeb603cf462db496/core/libs/prx/libc/include/General.hpp (lines 15-17)
- Definition: https://github.com/boykopovar/AnyPS5/blob/a6bb84be17d6c58584ce6bdbfeb603cf462db496/core/libs/prx/libc/src/General.cpp (around lines 1020-1030)
- Emscripten target: https://github.com/boykopovar/AnyPS5/blob/a6bb84be17d6c58584ce6bdbfeb603cf462db496/core/libs/tests/emscripten/CMakeLists.txt
- Test stub: https://github.com/boykopovar/AnyPS5/blob/a6bb84be17d6c58584ce6bdbfeb603cf462db496/core/libs/tests/emscripten/EmscriptenModuleUnwind.cpp (line 18)
- Hosted log:
library-portabilityjob on a6bb84b
Not verified
- The 16 ABI findings.
- Whether any other test target builds
Module.cppwithoutGeneral.cpp. - The Windows result (cancelled).
To get this to a good state
- Define
NotImplementedAt_nid_no_patchinEmscriptenModuleUnwind.cpp, or change the macro so the Emscripten target still links. Rerunlibrary-portability.
# Conflicts: # docs/dev/debt/libc.md
# Conflicts: # core/libs/prx/libc/CMakeLists.txt
NotImplemented_nid_no_patch now expands to NotImplementedAt_nid_no_patch, so Module.cpp in emscripten_module_unwind_tests references the located entry point, which that test target does not link from libc. Stub it next to the existing one.
The Start-time checkpoint calls Snapshot before the exit hook runs, so the function-local static regexes it uses (and the component list) were constructed early and destroyed by the library's finalizer before FinishAtExit read them. A run with a title id then crashed at exit. Allocate them once and never destroy them.
The Emscripten link error is fixed on the current head ba6ccc0: the library-portability job passes there. Dismissing as met; happy to look again if you see anything else.
✅ AMD GPU test: passedPR head
Unstable on main (5, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (14, not counted against this PR)Passed on retry (2, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validation IDs already present on main (4 IDs in 811 tests)Skipped (62)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
…ruction FindFrameFast (Linux) and IndexFrames (Windows) cache each image's data in a function-local static std::map guarded by a static std::mutex. Both are destroyed at exit when libc.prx is finalized, while another thread can still be throwing. Since #14235 the run report reads the title metadata on a detached thread, and in the ASan nightly the throw from AppMetadata's copyToFixedBuffer in that thread reads the freed map (heap-use-after-free at Unwind.cpp:233) in download_data_mount_invalid, guest_flexible_memory_invalid and three guest_convert_keycode_title tests. Allocate the caches and their mutexes and never destroy them, as libkernel does for its unwind images, its frame table cache and its thread stacks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Writes the run report when a converted game ends:
anyps5-report.json, in the format of #14165. It holds the build revision and whether the build is modified, the game (title ID, content version, name), the machine (OS version, CPU model, memory), and the list of unimplemented functions that were called. It is on by default;--aps5-report=offorAPS5_REPORT=0turns it off (--aps5-report=on/APS5_REPORT=1forces it on for a process that is not a converted game). With the report off nothing is collected or written.This is the second of four PRs. It writes only what a run that ends through
exitcan know. Milestones, frame counts, GPU, shader and image-format counters are marked as not collected (coveragefalse); they come in the next PR. A run that crashes, aborts or is killed writes no report yet; that is the last PR.reports/<run id>/in the data folder. Written atomically (temporary file, then rename) through a folder walk that refuses links.exitand_exit; on Linux and macOS also when the entry returns or the host callsstd::exit(anatexithook). On Windows onlyexitand_exitwrite a report, because a DLL's exit handlers run inside the loader lock.NotImplemented_nid_no_patch(name)becomes a macro that also passes__FILE__and__LINE__, somissing.functionscan name the library and the source line. The definitions are parenthesised so the macro does not rewrite them. The rootCMakeLists.txtadds-fmacro-prefix-map=<source dir>/=for C++ on GCC and Clang so that the paths of first-party code in the binaries are source-tree relative:stringsfinds no absolute source-tree path forcore/,tools/ordemo/files in any library or test binary (test binaries still contain build-directory strings such as.../libs/unpatched). C sources of the third-party libraries are not covered by the flag and still carry their build path.libkernelsupplies the game metadata through a provider; each library that registers itself with the report is stamped with the same build revision, soanyps5.modifiedisnullrather than a guess when a library comes from another build.Tested
Linux only.
run_report_tests: 47 passed, 0 failed, 2 not run (the comma-decimal locale test, when no such locale is installed; the junction test, Windows only).tools/tests/test_run_report_schema.py27 tests,tools/tests/test_run_report_docs.py6 tests, andtools/tests/validate_run_report_dump.py(every report the test binary writes validates against the schema): 10 valid. ctest of the tests selected from this diff (6 CMake directories, including the root one) pluspublic_headers(65): 502 tests, 100% passed, none skipped. The new testchild-guest-root-not-fixed-at-loadruns in a child process (so no earlier test can have touched the path resolver); it fails on the previous process-detection code and passes now (see below).Cost of the report, a game-less entry (
run_report_tests --child exit), 300 runs, three rounds, report off versus on, median of the round medians: 1.46 ms off, 1.71 ms on, so about 0.25 ms added to a run that writes one report (no title measured).Not run: Windows and macOS (the platform code in
RunReport.cpp), and the junction test (Windows only); the comma-decimal locale test is skipped when no such locale is installed. Not tested with a title.A bug found on the way: detecting a game process by resolving
/app0/...through the runtime's path resolver from a static initialiser fixes libc's guest root at load time (it records the working directory on first use). Six existing tests that change directory afterwards failed (guest_fopen_errors,guest_record_lock_owners,guest_path_errors,guest_app_icon,guest_app_info,guest_directory_link_types). This PR checks<cwd>/app0/sce_sys/param.json|param.sfodirectly instead.Things reviewers may question
app0/sce_sys/param.jsonor.sfounder the current directory at load);APS5_REPORT=1forces it for anything else.NotImplemented_nid_no_patchmacro changes 24,572 call sites in 366 files without editing them. Any code that declares or definesNotImplemented_nid_no_patch(const char*)in a file that includesGeneral.hppmust write it as(NotImplemented_nid_no_patch)(...); a test that stubs it and links library sources also needs aNotImplementedAt_nid_no_patchstub. This PR updates the four such files onmain. Open PRs that add such a definition in a test file: fix(libSceUsbd): retain devices during active USB operations #9803, feat(libressl3): report OpenSSL version strings #9970, feat(libSceJson2): implement allocator-backed values and recovery #10378, feat(equeue): implement macOS edge watches #12741 and feat(libkernel): support macOS pipe write readiness #13560 (each defines the stub in a test file that links library sources); they will fail to link until they addNotImplementedAt_nid_no_patch.__FILE__is embedded at each site; the prefix map above makes it source-relative for first-party C++ on GCC and Clang. MSVC has no equivalent flag, third-party C sources still embed their build path, and the schema test only runs wherejsonschemais installed (the workflow installs it;run_report_schemais registered in ctest only when Python has it).atexithook, so a return from the entry writes no report there. The Windows and macOS code has not been run.Finishwaits up to 3 seconds for a finish that is already in progress on another thread, and up to 1 second for the game metadata provider; a normal single-threaded exit does neither. Measured start-up and exit cost: see Tested.RunReport.cppis about 1,600 lines, of which roughly 400 are the platform path-safety code (WriteAtomically,ReadBounded,FolderIsReachable).RunReportRevision.hppand a CMake custom target stamp the revision intolibcand the libraries that register themselves.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)