Repository navigation
fix(libSceVideoOut): refuse the output status with VRR for a handle without buffers - #17812
Merged
oneandonlydean merged 3 commits intoNov 15, 2026
Merged
Conversation
…RR of a handle without buffers On a PS5 (firmware 11.60, payload process) sceVideoOutGetOutputStatusWithVrr on a handle that was just opened, with no buffer registered, returns 0x8029001c and writes nothing. The tests that read the status register a buffer first. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ithout buffers sceVideoOutGetOutputStatusWithVrr returns 0x8029001c and writes nothing for a handle that has never had buffers registered, as sceVideoOutClearFlipMaster already does and as a PS5 does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…handle without buffers Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Author
|
Probe source (built with ps5-payload-sdk v0.45; sceVideoOutGetOutputStatusWithVrr probe.c (run at 08:24 UTC)/* Probe E: sceVideoOutGetOutputStatusWithVrr, sceVideoOutIsOutputSupported, sceVideoOutGetResolutionStatus and the
Delete*Event calls on a port that is not open, payload process, firmware 11.60 (debt libSceVideoOut.md:20, :27,
:28 and :18: what a payload process on a PS5 returns is not measured). It follows the earlier payload run that
opened the main bus: sceVideoOutOpen(0xff, 0, 0, NULL), only reads, and sceVideoOutClose on the probe's own
handle. No buffer is registered, no flip, mode or flip rate is changed, no event is added. The status buffers
are 128-byte marker buffers; only the return code, the number of changed bytes and a few numeric fields (the
resolution and dynamic range words, the refresh rate, the three 16-bit values at bytes 48, 50 and 52, and the
words of the resolution status) are printed. The Delete*Event cases use an equeue created by the probe and the
closed handle of the probe's own port. Nothing is written, nothing is sent. */
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h> /* only for kernel_get_fw_version() */
#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
/* Self limit: the runner can only close the connection, it cannot end the process on the console, so the probe ends
itself after PROBE_MAX_S seconds at the latest (set by the build script). */
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif
static void probe_alarm(int sig) {
static const char msg[] = "TIMEOUT\tprobe self limit\n";
(void)sig;
(void)!write(1, msg, sizeof msg - 1);
_exit(124);
}
/* Watchdog thread: alarm()/SIGALRM does not help when the main thread hangs in a blocking system call or IPC. The
thread sleeps PROBE_MAX_S seconds, writes TIMEOUT with write() and ends the process with _exit(124). alarm() stays
as a second safeguard. */
static void* probe_watchdog(void* arg) {
static const char msg[] = "TIMEOUT\tprobe watchdog thread\n";
unsigned left = PROBE_MAX_S;
(void)arg;
while (left) left = sleep(left);
(void)!write(1, msg, sizeof msg - 1);
_exit(124);
return 0;
}
static void probe_watchdog_start(void) {
pthread_t t;
if (pthread_create(&t, 0, probe_watchdog, 0) == 0) pthread_detach(t);
}
static int cases = 0;
static void probe_header(void) {
char utc[32];
time_t now = time(0);
probe_watchdog_start();
struct tm tmv;
gmtime_r(&now, &tmv);
strftime(utc, sizeof utc, "%Y-%m-%dT%H:%M:%SZ", &tmv);
printf("PROBE\t%s\tfw=0x%08x\tbuild=%s\tpid=%d\tutc=%s\n", PROBE_NAME, kernel_get_fw_version(), PROBE_BUILD,
getpid(), utc);
fflush(stdout);
}
static void probe_case(const char* id, const char* call, long ret, int err, const char* extra) {
printf("CASE\t%s\t%s\t%ld\t%d\t%s\n", id, call, ret, err, extra ? extra : "-");
fflush(stdout);
cases++;
}
static void probe_end(void) {
printf("END\t%d\n", cases);
fflush(stdout);
}
typedef int (*fn_open)(int, int, int, const void*);
typedef int (*fn_close)(int);
typedef int (*fn_status)(int, void*);
typedef int (*fn_supported)(int, unsigned long, const void*, void*, unsigned long);
typedef int (*fn_delete)(void*, int);
typedef int (*fn_ceq)(void**, const char*);
typedef int (*fn_deq)(void*);
#define BUF 128
static void rc_case(const char* id, const char* call, long r, int e) {
char extra[32];
snprintf(extra, sizeof extra, "0x%08x", (unsigned)r);
probe_case(id, call, r, e, extra);
}
int main(void) {
signal(SIGALRM, probe_alarm);
alarm(PROBE_MAX_S);
probe_header();
errno = 0;
void* vo = dlopen("libSceVideoOut.sprx", RTLD_LAZY);
probe_case("0", "load libSceVideoOut.sprx", vo ? 0 : -1, errno, vo ? "loaded" : dlerror());
if (!vo) { probe_end(); return 0; }
fn_open open_ = (fn_open)dlsym(vo, "sceVideoOutOpen");
fn_close close_ = (fn_close)dlsym(vo, "sceVideoOutClose");
fn_status withVrr = (fn_status)dlsym(vo, "sceVideoOutGetOutputStatusWithVrr");
fn_supported supported = (fn_supported)dlsym(vo, "sceVideoOutIsOutputSupported");
fn_status resolution = (fn_status)dlsym(vo, "sceVideoOutGetResolutionStatus");
fn_delete delFlip = (fn_delete)dlsym(vo, "sceVideoOutDeleteFlipEvent");
fn_delete delVblank = (fn_delete)dlsym(vo, "sceVideoOutDeleteVblankEvent");
fn_delete delPre = (fn_delete)dlsym(vo, "sceVideoOutDeletePreVblankStartEvent");
fn_delete delMode = (fn_delete)dlsym(vo, "sceVideoOutDeleteOutputModeEvent");
fn_delete delVrr = (fn_delete)dlsym(vo, "sceVideoOutDeleteVrrActiveStatusEvent");
fn_ceq ceq = (fn_ceq)dlsym(RTLD_DEFAULT, "sceKernelCreateEqueue");
fn_deq deq = (fn_deq)dlsym(RTLD_DEFAULT, "sceKernelDeleteEqueue");
char extra[160];
snprintf(extra, sizeof extra, "open=%d close=%d vrr=%d supported=%d resolution=%d delete=%d%d%d%d%d equeue=%d%d",
open_ != 0, close_ != 0, withVrr != 0, supported != 0, resolution != 0, delFlip != 0, delVblank != 0,
delPre != 0, delMode != 0, delVrr != 0, ceq != 0, deq != 0);
probe_case("0b", "dlsym of the VideoOut and equeue functions", 0, 0, extra);
if (!open_ || !close_ || !withVrr || !supported || !resolution) { probe_end(); return 0; }
errno = 0;
long h = open_(0xff, 0, 0, 0);
rc_case("1", "sceVideoOutOpen(0xff, 0, 0, NULL)", h, errno);
if (h < 0) { probe_end(); return 0; }
static unsigned char buf[BUF];
int changed, last;
memset(buf, 0x5a, sizeof buf);
errno = 0;
long r = withVrr((int)h, buf);
int e = errno;
changed = 0; last = -1;
for (int b = 0; b < BUF; ++b) if (buf[b] != 0x5a) { changed++; last = b; }
unsigned short w48, w50, w52;
unsigned res, dyn;
unsigned long refresh;
memcpy(&res, buf, 4); memcpy(&dyn, buf + 4, 4); memcpy(&refresh, buf + 8, 8);
memcpy(&w48, buf + 48, 2); memcpy(&w50, buf + 50, 2); memcpy(&w52, buf + 52, 2);
snprintf(extra, sizeof extra, "0x%08x changed=%d last_offset=%d resolution=0x%x dynamic_range=0x%x refresh=0x%lx u16_48=%u u16_50=%u u16_52=%u",
(unsigned)r, changed, last, res, dyn, refresh, w48, w50, w52);
probe_case("2", "sceVideoOutGetOutputStatusWithVrr(handle, &status)", r, e, extra);
static const unsigned long modes[] = {1, 15};
static unsigned char options[64];
for (int m = 0; m < 2; ++m) {
char id[16], call[96];
memset(options, 0, sizeof options);
errno = 0;
r = supported((int)h, modes[m], options, 0, 0);
snprintf(id, sizeof id, "3.%d", m + 1);
snprintf(call, sizeof call, "sceVideoOutIsOutputSupported(handle, mode %lu, zero options, NULL, 0)", modes[m]);
rc_case(id, call, r, errno);
}
memset(buf, 0x5a, sizeof buf);
errno = 0;
r = resolution((int)h, buf);
e = errno;
changed = 0; last = -1;
for (int b = 0; b < BUF; ++b) if (buf[b] != 0x5a) { changed++; last = b; }
unsigned fw, fh, pw, ph, flagsw, size_bits;
unsigned long rr;
float inch;
memcpy(&fw, buf, 4); memcpy(&fh, buf + 4, 4); memcpy(&pw, buf + 8, 4); memcpy(&ph, buf + 12, 4);
memcpy(&rr, buf + 16, 8); memcpy(&inch, buf + 24, 4); memcpy(&size_bits, buf + 24, 4); memcpy(&flagsw, buf + 28, 4);
snprintf(extra, sizeof extra, "0x%08x changed=%d last_offset=%d full=%ux%u pane=%ux%u refresh=0x%lx screen_size_bits=0x%08x word7=0x%08x",
(unsigned)r, changed, last, fw, fh, pw, ph, rr, size_bits, flagsw);
probe_case("4", "sceVideoOutGetResolutionStatus(handle, &status)", r, e, extra);
errno = 0;
long c = close_((int)h);
rc_case("5", "sceVideoOutClose(own handle)", c, errno);
if (ceq && deq && delFlip && delVblank && delPre && delMode && delVrr) {
void* eq = 0;
errno = 0;
long q = ceq(&eq, "probe_e");
rc_case("6", "sceKernelCreateEqueue(&eq, name)", q, errno);
if (q == 0 && eq) {
errno = 0; r = delFlip(eq, (int)h); rc_case("7.1", "sceVideoOutDeleteFlipEvent(eq, closed handle)", r, errno);
errno = 0; r = delVblank(eq, (int)h); rc_case("7.2", "sceVideoOutDeleteVblankEvent(eq, closed handle)", r, errno);
errno = 0; r = delPre(eq, (int)h); rc_case("7.3", "sceVideoOutDeletePreVblankStartEvent(eq, closed handle)", r, errno);
errno = 0; r = delMode(eq, (int)h); rc_case("7.4", "sceVideoOutDeleteOutputModeEvent(eq, closed handle)", r, errno);
errno = 0; r = delVrr(eq, (int)h); rc_case("7.5", "sceVideoOutDeleteVrrActiveStatusEvent(eq, closed handle)", r, errno);
errno = 0; r = deq(eq); rc_case("8", "sceKernelDeleteEqueue(eq)", r, errno);
}
} else {
probe_case("6", "Delete*Event cases", -1, 0, "skipped: symbol missing");
}
probe_end();
return 0;
}raw output (run at 08:24 UTC)AI-assisted (Claude Code). 🤖 Generated with Claude Code |
milescoviello
approved these changes
Nov 9, 2026
milescoviello
left a comment
Contributor
There was a problem hiding this comment.
Read cee35fd34c against main.
- The check:
isFreshHandle(Output.cpp:304) is!cfg->buffersEverRegisteredunder the config mutex, the same testsceVideoOutClearFlipMasteruses (:321) for the same0x8029001C. It takes and releases the lock beforesceVideoOutGetOutputStatusWithVrrtakes it again, so there's no nested locking. - Order: the null-status (
INVALID_ADDRESS) and handle checks still come first. A fresh handle returns before the status is filled, which gives the measured "0 bytes written". - Scope: a handle that registered buffers and then unregistered them still reports, because
buffersEverRegisteredstays set. That case wasn't in the measurement, so keepingmain's answer for it is right. - Tests: the existing tests that read the VRR status now register a buffer first, and each first pins the measured refusal on the fresh handle.
AI-assisted: yes (Claude Code)
|
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.
|
12 tasks done
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
sceVideoOutGetOutputStatusWithVrrfilled the 80-byte status for a handle that has no buffer registered. A PS5 returns0x8029001Cand writes nothing for it. It now does the same, with the checksceVideoOutClearFlipMasteralready uses. The tests pin the refusal on a fresh handle and that the call succeeds once a buffer is registered. The debt entry forsceVideoOutGetOutputStatusWithVrr(docs/dev/debt/libSceVideoOut.md) said the console's0x8029001Ccheck "tests states that are not modelled and are never reported"; the entry now states the measured result for a fresh handle and keeps the0x8029001Bobject-field check as not modelled. Titles are not affected as far as measured: the title measurement (firmware 13.40) called it after its buffers were registered; no title is known to call it on a fresh handle.Tested
Measured on a PS5 with firmware 11.60 (
kernel_get_fw_version0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr), on 2026-11-09 at 08:24 UTC; the console's own clock read about 1 h 41 min more (see the first comment). A title process may differ.sceVideoOutOpen(0xff, 0, 0, NULL)with no buffer registeredmainbeforesceVideoOutGetOutputStatusWithVrr(handle, &status)return0x8029001C0x8029001CstatuswrittenOn Windows 10 Pro with MinGW GCC (WinLibs), a Release build,
ANYPS5_REQUIRE_VULKAN=1and a shader cache off, onmain67092e70b5the test commit alone failsvideo_out_flip_resolution_override,guest_video_out_resolution_statusandguest_video_out_hdr(3 of 3), and with the fix commit on the samemainall three pass.tools/check_conventions.py --base upstream/mainpasses. The runs used no Vulkan validation layer, because the added check returns before any Vulkan call.Overlap: the 24 other open pull requests that change
docs/dev/debt/libSceVideoOut.md,Output.cpp,Flip.cpp,GuestVideoOutHdr.cpporGuestVideoOutResolutionStatus.cpp(listed by update time) were checked on 2026-11-09 between 16:30 UTC and 16:38 UTC againstmainf6ed718e10. Four already conflict withmainwithout this change (#4040 and #14212 in the debt file, #12315 and #5021 in other files). #16463 (a documentation sync of 39 files, a different author) conflicts inGuestVideoOutHdr.cpponly with this change, because both touch that test file; whichever merges second needs a small rebase. The other nineteen merge cleanly with and without it, among them #17696, #17763, #16584 and #14106, which edit other entries of the debt file.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)AI-assisted (Claude Code).
🤖 Generated with Claude Code