Repository navigation
docs(debt): record that timespec_getres is not exported by libSceLibcInternal on firmware 11.60 - #21903
Merged
oneandonlydean merged 1 commit intoNov 16, 2026
Conversation
…Internal on firmware 11.60 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Author
|
Probe source (built with ps5-payload-sdk v0.45; probe.c#include <errno.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: on timeout the runner can only close the connection, not end the process on the console.
The probe ends itself after at most PROBE_MAX_S seconds (the build script sets timeout - 10 s). */
#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);
}
static int cases = 0;
static void probe_header(void) {
char utc[32];
time_t now = time(0);
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);
}
/* CASE: id, description of the call, return value as long, errno (0 if not set), extra (hex/bytes). */
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);
}
#include <dlfcn.h>
#include <setjmp.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/types.h>
static sigjmp_buf guard_env;
static volatile int guard_sig = 0;
static volatile int guard_active = 0;
static volatile int guard_hits = 0;
static void guard_handler(int s) {
static const char msg[] = "FAULT\tprobe guard: fault outside a guarded call or too many faults\n";
if(!guard_active || ++guard_hits > 8) {
(void)!write(1, msg, sizeof msg - 1);
_exit(125);
}
guard_sig = s;
guard_active = 0;
siglongjmp(guard_env, 1);
}
static void guard_arm(void) {
struct sigaction sa;
memset(&sa, 0, sizeof sa);
sa.sa_handler = guard_handler;
sigaction(SIGSEGV, &sa, 0);
sigaction(SIGBUS, &sa, 0);
sigaction(SIGABRT, &sa, 0);
}
#define CALL(rvar, evar, expr) do { errno = 0; guard_sig = 0; rvar = -1; if(sigsetjmp(guard_env, 1) == 0) { guard_active = 1; rvar = (expr); } guard_active = 0; evar = errno; } while(0)
/* timespec_getres of libSceLibcInternal.sprx (dlsym) on firmware 11.60 ('timespec_getres has unverified actual
console clock behavior ... only base 1 forwards to sceKernelClockGetres with clock ID 0, returning 1 exactly when that call returns 0').
Prototype int timespec_getres(struct timespec*, int base). The clock-id resolutions themselves are not measured here (an open pull request has
them). Bases -1, 0, 1, 2, 3 and 0x7fffffff, the result pre-filled with a marker: return value, whether the result was written, and its
values; then a second call with base 1 to see that it is stable. No NULL result (single call, last, guarded). At most 10 calls. */
typedef int (*tg_fn)(struct timespec*, int);
int main(void) {
signal(SIGALRM, probe_alarm);
alarm(PROBE_MAX_S);
probe_header();
guard_arm();
void* hl = dlopen("libSceLibcInternal.sprx", RTLD_LAZY);
tg_fn f = (tg_fn)(hl ? dlsym(hl, "timespec_getres") : 0);
char ex[8];
snprintf(ex, sizeof ex, "%d%d", !!hl, !!f);
probe_case("0", "dlopen libSceLibcInternal.sprx, dlsym timespec_getres (1 yes, 0 no)", 0, 0, ex);
if(!f) { probe_end(); return 0; }
static const int bases[] = {1, -1, 0, 2, 3, 0x7fffffff, 1};
char id[16], what[64], line[160];
int r, e;
for(size_t i = 0; i < sizeof bases / sizeof bases[0]; i++) {
struct timespec ts;
ts.tv_sec = 0x5a5a5a5a; ts.tv_nsec = 0x5a5a5a5a;
CALL(r, e, f(&ts, bases[i]));
int touched = !(ts.tv_sec == 0x5a5a5a5a && ts.tv_nsec == 0x5a5a5a5a);
snprintf(id, sizeof id, "a.%zu", i);
snprintf(what, sizeof what, "timespec_getres(&ts, %d)", bases[i]);
snprintf(line, sizeof line, "rc=%d written=%d sec=%lld nsec=%ld signal=%d", r, touched, touched ? (long long)ts.tv_sec : 0LL, touched ? (long)ts.tv_nsec : 0L, (int)guard_sig);
probe_case(id, what, guard_sig ? -1 : r, e, line);
}
CALL(r, e, f((struct timespec*)0, 1));
snprintf(line, sizeof line, "rc=%d signal=%d", r, (int)guard_sig);
probe_case("n", "timespec_getres(NULL, 1) (single call)", guard_sig ? -1 : r, e, line);
probe_end();
return 0;
}stdoutAI-assisted (Claude Code). |
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
The
timespec_getresentry indocs/dev/debt/libc.mdsays "has unverified actual console clock behavior and SDK-version coverage." A probe on a PS5 has now openedlibSceLibcInternal.sprxfrom a payload process withdlopenand looked uptimespec_getreswithdlsym: the library loaded and the lookup returned null (case 0, line 2 of the raw output; the result field reads10, one digit for the library and then one per name, 1 for found and 0 for not found, so the library loaded and the lookup of the name returned null). The pull request changes the entry through a debt fragment, as the contribution rules ask, to say that this module of firmware 11.60 does not exporttimespec_getres; no code changes.This shows one thing only: the console's
libSceLibcInternal.sprxon firmware 11.60 has no export of that name, so there was nothing to call and nothing to compare with the code of this library. Other probes of the same day found other functions of that module by name in the same way (for exampleqsort_sandsnwprintf_s), so the lookup works. A title's ownlibc.prx, which the code here follows in most entries, may exporttimespec_getres, and a payload process cannot look inside a title's modules; the entry therefore keeps the console behavior as unmeasured. Not measured: the behavior of the kernel callsceKernelClockGetresthat this library forwards to (a probe of that call can be made separately), and a title's ownlibc.prx.Tested
Measured on a PS5 with firmware 11.60 (
kernel_get_fw_version0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr) that loadslibSceLibcInternal.sprxwithdlopenand callsdlsymfortimespec_getres, on 2026-11-15 at 15:44 UTC. A title process may differ. The one case is case 0, line 2 of the raw output in the first comment.maindlopen("libSceLibcInternal.sprx")1)dlsymoftimespec_getres10: library found, name not found)libctools/check_conventions.py --base upstream/mainpasses with no error and no warning (the entry is 757 characters, up from 588). This is a documentation change, so no test was added or run, and no GPU test applies. Not tested: a title process, other firmware, other lookup routes into the module, and the cases listed above as not measured.Overlap: the other open pull requests that change the file of this branch (the fragment
docs/dev/debt/changes/docs-libc-timespec-getres-not-exported.md, a new file) or the debt entry it changes, found by reading the changed files of all 1762 open pull requests at about 19:40 UTC, by reading what they change indocs/dev/debt/libc.mdand in the fragments underdocs/dev/debt/changes/fortimespec_getres, and by searching their titles and branch names fortimespec_getres. The branch was test-merged on 2026-11-16 at about 19:49 UTC againstmaine2e77aa74a5(the branch is based on4b186fcca4c, an ancestor of it) and merges into it without a conflict;tools/debt_fold.py --checkapplies the fragment to thelibcdebt file of thatmainwithout an error, the text it changes occurs in exactly one entry, and no other fragment changes that entry. Three other open pull requests changeTime.cpp: #12315, which lists it but changes nothing in it againstmain, #10409 (struct tmsize) and #9447 (std::__sce_v2thread and clock calls); none of them changes a line that namestimespec_getresand no open pull request changes this debt entry. The merged result was not built or run; this is a documentation change.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)