Skip to content

Fix startup crash on malformed patch indexes and short CONTENT_ID#4171

Open
kernelstub wants to merge 1 commit intoshadps4-emu:mainfrom
kernelstub:main
Open

Fix startup crash on malformed patch indexes and short CONTENT_ID#4171
kernelstub wants to merge 1 commit intoshadps4-emu:mainfrom
kernelstub:main

Conversation

@kernelstub
Copy link
Copy Markdown

@kernelstub kernelstub commented Mar 24, 2026

Prevents early startup termination triggered by CUSA03173 when auto-patch repositories contain missing/unreadable/malformed files.json by adding open checks, JSON parse exception handling, and basic schema validation.

Hardens param.sfo handling by guarding CONTENT_ID substring extraction and falling back to TITLE_ID , and by catching invalid sdk_ver parsing from PUBTOOLINFO with a safe fallback to firmware version.

PS: Now it has Clang formating that @georgemoralis asked for, also remove exceptions for Pubtoolinfo and added logging for all cases for CONTENT_ID

Other PR #4159 I opened from wrong account.

Prevents early startup termination triggered by `CUSA03173` when
auto-patch repositories contain missing/unreadable/malformed
`files.json` by adding open checks, JSON parse exception handling, and
basic schema validation.

Hardens `param.sfo` handling by guarding `CONTENT_ID` substring
extraction and falling back to `TITLE_ID` , and by catching invalid
`sdk_ver` parsing from `PUBTOOLINFO` with a safe fallback to firmware
version.

PS: Now it has Clang formating that @georgemorallis asked for, also
remove exceptions for Pubtoolinfo and added logging for all cases for
`CONTENT_ID`
@kernelstub
Copy link
Copy Markdown
Author

You can close the other PR, this is the correct one.

@kernelstub
Copy link
Copy Markdown
Author

Looks good to me to merge, tests passed as well^^

@StevenMiller123
Copy link
Copy Markdown
Collaborator

Has this actually been checked against the issues it's supposed to fix?
I would still like to know more about the CONTENT_ID and PUBTOOLINFO issues you found, specifically what retail games trigger these issues.

@kernelstub
Copy link
Copy Markdown
Author

kernelstub commented Mar 25, 2026

Has this actually been checked against the issues it's supposed to fix?

I would still like to know more about the CONTENT_ID and PUBTOOLINFO issues you found, specifically what retail games trigger these issues.

Hi, yes @georgemoralis took a look at it, he just said clang formatting was left. Also yes issue fixes crash on the specific game.

If you need anything else I can do it at my break, im at work currently.

@georgemoralis aderfe ta issues exoum ftiaxti,einaiready gia merge, opote thes kanto^^

@red-prig
Copy link
Copy Markdown
Contributor

Has this actually been checked against the issues it's supposed to fix?
I would still like to know more about the CONTENT_ID and PUBTOOLINFO issues you found, specifically what retail games trigger these issues.

Hi, yes @georgemoralis took a look at it, he just said clang formatting was left. Also yes issue fixes crash on the specific game.

If you need anything else I can do it at my break, im at work currently.

@georgemoralis aderfe ta issues exoum ftiaxti,einaiready gia merge, opote thes kanto^^

you didn't answer the question

@kernelstub
Copy link
Copy Markdown
Author

Has this actually been checked against the issues it's supposed to fix?

I would still like to know more about the CONTENT_ID and PUBTOOLINFO issues you found, specifically what retail games trigger these issues.

Hi, yes @georgemoralis took a look at it, he just said clang formatting was left. Also yes issue fixes crash on the specific game.

If you need anything else I can do it at my break, im at work currently.

@georgemoralis aderfe ta issues exoum ftiaxti,einaiready gia merge, opote thes kanto^^

you didn't answer the question

I will later then ^^ I'll go in depth for you on how the atoms are built and protons also and from there ill build it up to explaining what this fixes after i find the logs the guy sent on discord ✌🏻

@kalaposfos13
Copy link
Copy Markdown
Member

https://discord.com/channels/1080089157554155590/1258386683691274361/1485075159965634671
The aforementioned log is here, and the person's issue was not adding extra direct memory to use with the 1440p patch, which is unrelated to this PR.

@StevenMiller123
Copy link
Copy Markdown
Collaborator

StevenMiller123 commented Mar 25, 2026

@georgemoralis has a bit of a track record of accepting/making questionable changes, that's why I took a separate look in the first place.
I also looked at the Discord conversation (I knew about it when reviewing your prior PR too), and as noted by others, the issue you claim to be solving has no relation to this PR's changes.

While I can't speak about the patching code, the changes you're making to param.sfo parsing are aiming to solve a problem that doesn't exist. There's no point in them unless you can prove otherwise.

@kernelstub
Copy link
Copy Markdown
Author

This is mostly about making the parsing safer rather than fixing one specific title.

For CONTENT_ID, the issue happens when it’s missing, too short, or not in the expected format. The old code assumes it’s always valid, which can lead to wrong IDs. Now it just falls back to TITLE_ID and logs it.

For PUBTOOLINFO, sdk_ver isn’t always present or well formatted. The old logic assumed it was, which could break parsing. The fix adds checks and falls back to the firmware version if needed.

I don’t have specific retail titles that consistently trigger this it’s mostly edge cases with inconsistent metadata but this makes the code handle those safely.

@StevenMiller123
Copy link
Copy Markdown
Collaborator

The important context here is that the param.sfo fields are set by the PS4 SDK (or for homebrew, the OpenOrbis Toolchain). In both cases, our current code works, and we don't need this extra validation.
CONTENT_ID needs to be valid for a game to run on real hardware. While you're correct about sdk_ver missing from PUBTOOLINFO, that case is already appropriately handled. OpenOrbis homebrews would not function if there was an issue there.

@StevenMiller123
Copy link
Copy Markdown
Collaborator

I'll let other devs weigh in here, but I don't see a point in changing how we handle those fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants