Skip to content

fix(ajm): preserve decoder instance context ownership - #16201

Open
JJenkx wants to merge 1 commit into
boykopovar:mainfrom
JJenkx:fix/ajm-instance-context-ownership-20261105
Open

JJenkx wants to merge 1 commit into
boykopovar:mainfrom
JJenkx:fix/ajm-instance-context-ownership-20261105

Conversation

@JJenkx

@JJenkx JJenkx commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

What

A caller can currently create an AJM decoder using context0, or delete an instance owned by another initialized context. On main 151a2cb6e274, a foreign-context destroy returns0 and the real owner's subsequent destroy returns 0x80930003 because its instance has already been erased.

Validate the context before creating or destroying an instance, retain its owning context in the private instance state, and reject foreign-context destruction with SCE_AJM_ERROR_INVALID_INSTANCE. The owner can still destroy its instance afterward. The context checks follow shadPS4's AJM entry points and its per-context instance destruction. These are reference-implementation semantics, not a PS5 module or console measurement.

Finalization still does not invalidate contexts or release their resources, and batch jobs still look up instances globally. Those existing gaps remain explicit in the debt entry; no title unblock, audio improvement or performance gain is claimed.

Tested

Linux x86-64, Ryzen9 7950X, GCC16.2.1, CMake Release, BUILD_TESTING=ON. Built actual libSceAjm.native, libSceAjmi and the selected fixtures.

  • Main: all7 existing AJM/ATRAC9 CPU tests pass, zero skips.
  • New ownership regression with main implementation: guest_ajm fails; same executable with frozen main module bank also fails.
  • Change: all7 suites pass, zero skips (guest_ajm, AAC multichannel, vibration, WVorbis, teardown, ATRAC9 gradient and config-data).
  • Separate same-executable probes demonstrate invalid-context creation and foreign-context deletion on main, and correct errors/owner preservation with this change. ldd verifies the selected modules.
  • Public-header audit:406 libraries/30604 exports pass. Conventions and whitespace pass.

Source diff, baseline/fix build/test/JUnit logs, same-executable controls, source/library pins and manual overlap review, SHA-256 f24ff6dbce5b1365f09eae5ae16db65866a6601211ff27d253e878b6449e1975 (download verified).

The required overlap check compared1904 open PRs. It initially reported an additive debt conflict with #15906; moving this note to a separate entry makes the two branches merge cleanly. #13486 and #14212 already conflict with main, so I manually compared their topic diffs and both create/destroy bodies: neither implements these ownership checks. #13486's remaining conflicts are relinker files; #14212 is debt formatting. No dependency on those branches.

No fresh Windows, PS5 SDK-module, console, game/GPU or full-SDK run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant