Skip to content

docs(debt): record that timespec_getres is not exported by libSceLibcInternal on firmware 11.60 - #21903

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libc-timespec-getres-not-exported
Nov 16, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libc-timespec-getres-not-exported

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

What

The timespec_getres entry in docs/dev/debt/libc.md says "has unverified actual console clock behavior and SDK-version coverage." A probe on a PS5 has now opened libSceLibcInternal.sprx from a payload process with dlopen and looked up timespec_getres with dlsym: the library loaded and the lookup returned null (case 0, line 2 of the raw output; the result field reads 10, 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 export timespec_getres; no code changes.

This shows one thing only: the console's libSceLibcInternal.sprx on 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 example qsort_s and snwprintf_s), so the lookup works. A title's own libc.prx, which the code here follows in most entries, may export timespec_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 call sceKernelClockGetres that this library forwards to (a probe of that call can be made separately), and a title's own libc.prx.

Tested

Measured on a PS5 with firmware 11.60 (kernel_get_fw_version 0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr) that loads libSceLibcInternal.sprx with dlopen and calls dlsym for timespec_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.

Call PS5 payload process, firmware 11.60 AnyPS5 main in the entry
dlopen("libSceLibcInternal.sprx") loaded (first digit 1) not applicable now stated
dlsym of timespec_getres null (10: library found, name not found) implemented in libc now stated

tools/check_conventions.py --base upstream/main passes 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 in docs/dev/debt/libc.md and in the fragments under docs/dev/debt/changes/ for timespec_getres, and by searching their titles and branch names for timespec_getres. The branch was test-merged on 2026-11-16 at about 19:49 UTC against main e2e77aa74a5 (the branch is based on 4b186fcca4c, an ancestor of it) and merges into it without a conflict; tools/debt_fold.py --check applies the fragment to the libc debt file of that main without an error, the text it changes occurs in exactly one entry, and no other fragment changes that entry. Three other open pull requests change Time.cpp: #12315, which lists it but changes nothing in it against main, #10409 (struct tm size) and #9447 (std::__sce_v2 thread and clock calls); none of them changes a line that names timespec_getres and no open pull request changes this debt entry. The merged result was not built or run; this is a documentation change.

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 (documentation only)
  • AI-assisted: yes

…Internal on firmware 11.60

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Probe source (built with ps5-payload-sdk v0.45; PROBE_BUILD is the first 12 hex digits of the source's SHA-256, 39aeb126f376) and its raw output from the run on 2026-11-15 at 15:44 UTC. The clock in the PROBE line is the console's own clock. The probe opens libSceLibcInternal.sprx and looks up timespec_getres with dlsym; when a name is missing it prints the result and ends, which is the whole result. An internal probe number and case reference in the header comment were removed; the code is unchanged, and the build ID is the hash of the original file. The case text in the raw output may name a different library than libSceLibcInternal.sprx; the source above is what was called.

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;
}
stdout
PROBE	libc_timespec_getres	fw=0x11600005	build=39aeb126f376	pid=165	utc=2026-11-15T17:26:23Z
CASE	0	dlopen libSceLibcInternal.sprx, dlsym timespec_getres (1 yes, 0 no)	0	0	10
END	1

AI-assisted (Claude Code).

@github-actions github-actions Bot added the docs label Nov 16, 2026
@oneandonlydean
oneandonlydean merged commit 459f4f8 into boykopovar:main Nov 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants