feat(libSceContentExport): end the session in sceContentExportFromData so GetProgress answers #28370
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28370"
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 zaryabzip on 2026-11-30T10:03:55Z.
What
sceContentExportGetProgressthrows after a plainsceContentExportFromData. Onmainthe export leaves its session in a host-onlyAfterFromDatastate, andGetProgresscallsNotImplemented_nid_no_patchon it. So a title that checks progress after a data export stops there. With this changeFromDataends the session, andGetProgressanswers as for any ended export: 100, or0x809D3002below SDK 6.00.Source. @noisyweather's reading of firmware 9.20's
libSceContentExport.sprxon #25863 (comment). It is disassembly only, not measured on a console.session+0x10). There are three of state 2, "last export ended, success or failure":0x6c5(the file export),0x1bd9(FromDataWithThumbnail) and0x137d.sceContentExportFromData's call into the shared chunk writer at0x118f. That call sits between the third routine's state-5 store (0x1067, writing through callbacks), its state-6 store (0x12de, registering) and that state-2 store at0x137d. This is the same 5 → 6 → 2 sequence the reading gives forFromDataWithThumbnailin full.GetProgresson state 2 answers 100 at SDK 6.00 or later and0x809D3002below.mainalready returns that for other ended sessions.The routine around
0x1067–0x137dis attributed to plainFromDatafrom that chunk-writer call, not read by name. The entry says so. It's the inference I gave on #25863 when @Alexofbulgaria asked.Change (
Export.cpp):FromDataends the session when it returns past the session check, with success or an error, as the reading's state 2 is "ended, success or failure". It ends it only if its slot wasn't finished and started again during the callbacks, using #28141's per-slot start count. A callback that queries progress mid-export sees the session as it was, not ended. (67b339b012, from @MarcZX10's review.)0x809D3006, as a host limit. AnExportReservationgives the index back and ends the session on every exit, exceptions included (2301fe0b84, from @ligmaSec's allocation-failure check). In the reading the name comes from the session object, and the module unlinks nothing on this path. (From @MarcZX10's and CodeRabbit's reviews:67b339b012,0302302ba2,7c60c8708c.)AfterFromDatastate andGetProgress's throw on it go.FromDataWithThumbnail.Built on #28141, which has merged, so the diff here is only this PR's commits.
Debt.
main's pendingfeat-content-export-progress-checks.md, edited by #28141, drops "GetProgress throws after sceContentExportFromData."feat-content-export-fromdata-ends-session.mdadds a Functional entry with the end state and its grounds.Test (
GuestContentExport.cpp, ctestguest_content_export), on an idle session:FromData→GetProgress100, and0x809D3002at SDK 5.00;FinishandStart, aFromDatawhose byte count differs from its length →0x809D3016, andGetProgressgoes from 0 to 100;GetProgresson its own idle session gets 0, and the session ends onceFromDatareturns;FromDataon the third session, gets a different path from the outer export, each file holding its own bytes. A later export goes back to the outer path;FromData64 deep gets0x809D3006for the 65th, and a later export goes back to the first name.Tested
d6a3e3420f. Windows 11 Home 25H2 (26200.9974), i7-11800H, WinLibs GCC 15.2.0 r7 UCRT, CMake 4.3.1, Ninja 1.13.2, Release,BUILD_TESTING=ON.guest_content_exportpasses. No warnings.Export.cpp(57147fde81) with this test. It aborts (0xc0000409) withsceContentExportGetProgress not implemented.d6a3e3420f. Ubuntu 24.04, GCC 13.3, Ninja, Release.guest_content_exportpasses. Control:main'sExport.cppwith the new test aborts.67b339b012, the review fix. Same machine and toolchain as above.guest_content_exportpasses with no warnings, and the branch merges cleanly withmain76d0a4a7dc. Control:d6a3e3420f'sExport.cppwith the new rows aborts at the mid-export probe (GuestContentExport.cpp:396), where the old code already reports 100. The macOS harness gives the same result.7c60c8708c, the per-export names. Same machine and toolchain as above.guest_content_exportpasses with no warnings, and the branch merges cleanly withmain6a1b7a1920. Control:0302302ba2'sExport.cppwith the new rows aborts at the nested-export row (GuestContentExport.cpp:434). Both restarts succeed and the nestedFromDatareturns 0, but it gets the outer export's temp name. The macOS harness gives the same result.2301fe0b84, the fixed name mask. Same machine and toolchain as above.guest_content_exportpasses with no warnings, and the branch merges cleanly withmainb97867d3ce. Control:7c60c8708c'sExport.cpppasses every earlier row, then recurses inside the 64-deep row (GuestContentExport.cpp:463) until the stack overflows (0xc00000fd), without ever returning0x809D3006. The macOS harness gives the same result.Export.cppwith this test aborts at the first newGetProgress, withsceContentExportGetProgress not implemented.7c60c8708c. The wholeGuestContentExportfixture passes. Their extra allocation-failure check found that the name pool could throw before the first callback. Fixed in2301fe0b84.2301fe0b84.guest_content_exportpasses, the 64-deep reentry and name reuse rows included.git merge-treefinds no conflict withmain(b3c7769bc5) or with any open PR that merges withmain.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T10:05:29Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: preserve session state until
FromDatahas actually passed its validation and completed its callback/file work.What I ran
d6a3e3420fe5b0c4cf6dc48d36e0667c904ae990using the prepared diff andrepo_read.py.core/libs/prx/libSceContentExport/Export.cpp,core/libs/tests/GuestContentExport.cpp, and both changed debt files. All files marked reviewed in the manifest were read; no changed files were excluded.Results
Findings
Blocking
core/libs/prx/libSceContentExport/Export.cpp:397sets the session toEndedimmediately after the session lookup, before content type validation or callback/file processing. On an invalid content type, callback error, or failed write,FromDatareturns an error whileGetProgressreports 100. More seriously, the callback runs after the session lock is released, so another thread can callsceContentExportFinishandsceContentExportStartfor the same ID while the original export is still running; the subsequent callback work can then overwrite the new session’s temporary file, despiteFromDataWithThumbnailguarding this restart case. Mark the session ended only after the export finishes, and preserve the restarted session on completion.Non-blocking
None.
Not verified
To get this to a good state
Move the
Endedtransition to the completion path and guard against ending a newly restarted session, then rerun the reportedguest_content_exporttests and their control.Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-30T10:05:39Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
d6a3e3420f:tools/check_conventions.pypassed.guest_content_export_testsbuilt cleanly.guest_content_export):core/libs/prx/libSceContentExport/Export.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T10:13:02Z.
Review: COMMENTED
Actionable comments posted: 2
Architecture findings (2)
Advisory architecture findings (2)
5804e79f-bfbf-4b86-87d0-2819d7644ad3Reviewing files that changed from the base of the PR and between
b3c7769bc5andd6a3e3420f.core/libs/prx/libSceContentExport/Export.cppcore/libs/tests/GuestContentExport.cppdocs/dev/debt/changes/feat-content-export-fromdata-ends-session.mddocs/dev/debt/changes/feat-content-export-progress-checks.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-30T19:48:43Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
67b339b012:tools/check_conventions.pypassed.guest_content_export_testsbuilt cleanly.guest_content_export):core/libs/prx/libSceContentExport/Export.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T19:49:34Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes have no verified blocking defects, and the inspected implementation and tests support merging.
What I ran
Reviewed head
67b339b01213f04648fad9ceac292c231e590addagainst the prepared diff and head files. No merged preview, build, or test was run. Read-only inspection usedcat,sed, andrepo_read.py cat.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Export.cppat the reviewed headGuestContentExport.cppat the reviewed headNot verified
No build, tests, console behavior, or author-reported Windows, Linux, and macOS results were independently verified. All four files listed as reviewed were read;
files.jsonlists no excluded files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T19:53:16Z.
Review: COMMENTED
Actionable comments posted: 1
Architecture findings (2)
Advisory architecture findings (2)
ab2834ed-46cf-4eaf-8d19-261f4c228d4cReviewing files that changed from the base of the PR and between
d6a3e3420fand67b339b012.core/libs/prx/libSceContentExport/Export.cppcore/libs/tests/GuestContentExport.cppdocs/dev/debt/changes/feat-content-export-fromdata-ends-session.mddocs/dev/debt/changes/feat-content-export-progress-checks.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T07:49:28Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: give each active export a distinct temporary path so a nested session restart cannot overwrite an in-flight export.
What I ran
Reviewed head
0302302ba22c4c7a834b0ebfbb987751031111ddusing the prepared review files. No merged preview was run. The review shell’s OS and toolchain were not queried. I did not run tests or builds.Results
files.jsonlists noneNegative control
The author reports that the new test aborts against earlier code on Windows, Linux, and macOS. I did not run that control.
Findings
Blocking
core/libs/prx/libSceContentExport/Export.cpp:292andcore/libs/prx/libSceContentExport/Export.cpp:356: temporary paths use only the start count’s parity. If a callback finishes and restarts its session twice, then starts another export before the original callback returns, the original and nested export have the same path.WriteCallbackFileopens with truncation before invoking callbacks, so the nested export can truncate or overwrite the still-active export’s file. Use a path identity unique among active exports, and add a reentrant callback regression test. Pinned sourceNon-blocking
None.
Sources
The changed
Export.cpp,GuestContentExport.cpp, and both changed debt documents were inspected from the prepared files. The first pinned-reader call returned source context; later reader calls could not complete because the reader attempted to write its log in the read-only run folder. No files are listed as excluded.Not verified
Tests, the author-reported negative controls, console behavior, and a merged preview were not run or confirmed. The unmodified portions of the changed files were not read.
To get this to a good state
Use a distinct temporary path for every active export and add a regression test that nests exports across repeated finish/restart callbacks. Then rerun the content export test on the new head.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T07:52:39Z.
Review: COMMENTED
🏛️ Architecture findings (2)
Advisory architecture findings (2)
💬 Code review
f939d541-ced4-4d1b-8a7d-c2891e2a8f24Reviewing files that changed from the base of the PR and between
67b339b012and0302302ba2.core/libs/prx/libSceContentExport/Export.cppdocs/dev/debt/changes/feat-content-export-fromdata-ends-session.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T19:49:11Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes correctly end data export sessions while preserving sessions restarted during callbacks, and assign distinct paths to overlapping exports.
What I ran
Reviewed head
7c60c8708c789e7fd92683208371cc6d4bfac5dfand the prepared diff; inspected changed code and relevant callers through the pinned reader. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
I did not run tests, a build, or the reported negative controls. I read the reviewed files
core/libs/prx/libSceContentExport/Export.cpp,core/libs/tests/GuestContentExport.cpp,docs/dev/debt/changes/feat-content-export-fromdata-ends-session.md, anddocs/dev/debt/changes/feat-content-export-progress-checks.md;files.jsonlists no excluded files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T19:55:07Z.
Review: COMMENTED
🏛️ Architecture findings (4)
Advisory architecture findings (4)
2813a887-3b0d-484e-a2e7-fc1d7599fbf1Reviewing files that changed from the base of the PR and between
0302302ba2and7c60c8708c.core/libs/prx/libSceContentExport/Export.cppcore/libs/tests/GuestContentExport.cppdocs/dev/debt/changes/feat-content-export-fromdata-ends-session.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T05:46:12Z.
Review: COMMENTED
The complete
GuestContentExportfixture passed on Linux. An additional allocation-failure check against the PR and the exact pre-change source found a guest-visible regression before the first callback.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T07:49:47Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes consistently implement the stated host behavior at head
2301fe0b84471d2ea952cb57d536184f69c9668f, and I found no blocking defects.What I ran
Reviewed the prepared diff and all four changed files at the pinned head. No build or tests were run in this review; the environment and toolchain were not applicable.
Files read:
core/libs/prx/libSceContentExport/Export.cpp,core/libs/tests/GuestContentExport.cpp,docs/dev/debt/changes/feat-content-export-fromdata-ends-session.md, anddocs/dev/debt/changes/feat-content-export-progress-checks.md. No changed files were excluded.Results
Negative control
Not run in this review. The description reports author and reviewer controls, but those results were not independently reproduced.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The reported Windows, Linux, and macOS test runs were not independently reproduced. The firmware 9.20 interpretation is based on the description’s cited disassembly reading; no console behavior was verified in this review.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T07:53:43Z.
Review: COMMENTED
Actionable comments
8c313e4f-3c47-427a-89d9-9fe1a466cceaReviewing files that changed from the base of the PR and between
7c60c8708cand2301fe0b84.core/libs/prx/libSceContentExport/Export.cppcore/libs/tests/GuestContentExport.cppdocs/dev/debt/changes/feat-content-export-fromdata-ends-session.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T20:46:10Z.
Review: COMMENTED
The revised session guard and reservation mask passed
guest_content_exporton Linux, including the new 64-deep reentry case and name reuse after unwinding. The previous failure from allocating a name-set node is removed. Is the resulting 64-reservation limit andErrorNoMemoryresult measured on the guest? The new case locks both values into the test.Source review at
2301fe0b84. The exact head trial-merges onto700fae9438.AI-assisted: yes.