Repository navigation
Conversation
…measurement Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Probe source and raw output for the measurement in the description. Firmware 11.60 ( 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>
#include <sys/mman.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);
sigaction(SIGILL, &sa, 0);
sigaction(SIGTRAP, &sa, 0);
sigaction(SIGFPE, &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)
/* Probe: strtod AND wcstod of libSceLibcInternal.sprx on firmware 11.60 for decimal and hexadecimal strings with a subnormal or underflowing result, in the floating point control state the probe process starts with and in the standard state. The earlier probe libc_strtod_subnormal_mxcsr (two runs) covered decimal strtod only; the entry says the console's wcstod is unmeasured and that the hexadecimal subnormal rule matches one title's libc.prx only.
ASSUMED prototypes (not known for the console): double strtod(const char*, char**) and double wcstod(const wchar_t*, wchar_t**) with a 32-bit wchar_t. Own static strings only (narrow and wide, the same text), the end pointer goes to an own static pointer; no file, no network, no init. THE PROBE SETS THE MXCSR OF ITS OWN PROCESS (ldmxcsr) to the standard value 0x1f80 in state s and restores the saved value afterwards.
Case 0.dlopen.1/2, 1.ctrl, 2 (dlsym of strtod and wcstod), m (the MXCSR found, hex). Two states, each with 'next:' before it: f = the MXCSR found, s = 0x1f80 set in this process. In each state, for both functions, the 14 strings of a fixed table: decimal "1e-307", "2.2250738585072014e-308", "2.2250738585072011e-308", "4.9406564584124654e-324", "2.4703282292062327e-324", "2.4703282292062328e-324", "1e-400", "-1e-400" and hexadecimal "0x1p-1022" (normal, control), "0x1p-1074", "0x1p-1075", "0x1.8p-1074", "0x1p-1076", "0x0.0000000000001p-1022": printed per call the table index, the result as 64-bit hex, errno (set to 0 before), the number of characters consumed, and the signal. Guard (SIGSEGV, SIGBUS, SIGABRT, SIGILL, SIGTRAP, SIGFPE) around every call; the run ends at the first signal (the saved MXCSR is restored first). */
static void* probe_watchdog(void* arg) {
static const char msg[] = "TIMEOUT\tprobe watchdog thread\n";
(void)arg;
{ unsigned left = PROBE_MAX_S; 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);
}
#include <math.h>
#include <wchar.h>
#include <xmmintrin.h>
typedef double (*d_fn)(const char*, char**);
typedef double (*w_fn)(const wchar_t*, wchar_t**);
static uint64_t dbits(double d) { uint64_t u; memcpy(&u, &d, 8); return u; }
#define NSTR 14
static const char* NS[NSTR] = {"1e-307", "2.2250738585072014e-308", "2.2250738585072011e-308", "4.9406564584124654e-324", "2.4703282292062327e-324", "2.4703282292062328e-324", "1e-400", "-1e-400",
"0x1p-1022", "0x1p-1074", "0x1p-1075", "0x1.8p-1074", "0x1p-1076", "0x0.0000000000001p-1022"};
static const wchar_t* WS[NSTR] = {L"1e-307", L"2.2250738585072014e-308", L"2.2250738585072011e-308", L"4.9406564584124654e-324", L"2.4703282292062327e-324", L"2.4703282292062328e-324", L"1e-400", L"-1e-400",
L"0x1p-1022", L"0x1p-1074", L"0x1p-1075", L"0x1.8p-1074", L"0x1p-1076", L"0x0.0000000000001p-1022"};
int main(void) {
signal(SIGALRM, probe_alarm);
alarm(PROBE_MAX_S);
probe_header();
probe_watchdog_start();
guard_arm();
char line[400];
probe_case("0.pre", "next: dlopen of libSceLibcInternal.sprx; a hang here ends the run by timeout", 0, 0, "-");
void* h1 = dlopen("libSceLibcInternal.sprx", RTLD_LAZY);
probe_case("0.dlopen.1", "dlopen(libSceLibcInternal.sprx) first attempt", h1 != 0, 0, "-");
void* h2 = dlopen("libSceLibcInternal.sprx", RTLD_LAZY);
probe_case("0.dlopen.2", "dlopen(libSceLibcInternal.sprx) second attempt", h2 != 0, 0, "-");
void* lib = h1 ? h1 : h2;
if(!lib) { probe_end(); return 0; }
void* kern = dlopen("libkernel.sprx", RTLD_LAZY);
void* ctl = kern ? dlsym(kern, "sceKernelGetCurrentCpu") : 0;
void* neg = kern ? dlsym(kern, "sceKernelNoSuchControlAps5") : 0;
snprintf(line, sizeof line, "control sceKernelGetCurrentCpu resolves %d, negative control resolves %d (1 yes, 0 no)", ctl != 0, neg != 0);
probe_case("1.ctrl", "dlsym in libkernel.sprx: control and negative control", 0, 0, line);
d_fn f_strtod = (d_fn)dlsym(lib, "strtod");
w_fn f_wcstod = (w_fn)dlsym(lib, "wcstod");
void* negl = dlsym(lib, "strtoNoSuchControlAps5");
snprintf(line, sizeof line, "dlsym in libSceLibcInternal.sprx: strtod %d, wcstod %d, negative control %d, sizeof(wchar_t) %d (1 yes, 0 no)", f_strtod != 0, f_wcstod != 0, negl != 0, (int)sizeof(wchar_t));
probe_case("2", "name stage", 0, 0, line);
if(!ctl || neg || !f_strtod || !f_wcstod || negl) { probe_end(); return 0; }
const unsigned saved = _mm_getcsr();
snprintf(line, sizeof line, "mxcsr_found=0x%08x", saved);
probe_case("m", "MXCSR of the probe process at the start", 0, 0, line);
static const char* SN[2] = {"f", "s"};
for(int st = 0; st < 2; st++) {
char pre[200];
snprintf(pre, sizeof pre, "next: state %s (%s); a signal here ends the run", SN[st], st == 0 ? "the MXCSR found" : "standard 0x1f80 set in this process, restored afterwards");
probe_case("st.pre", pre, 0, 0, "-");
if(st) _mm_setcsr(0x1f80u);
snprintf(line, sizeof line, "state=%s mxcsr_now=0x%08x", SN[st], _mm_getcsr());
probe_case(st ? "st.s" : "st.f", "MXCSR in effect for this state", 0, 0, line);
for(int k = 0; k < 2 * NSTR; k++) {
int wide = k >= NSTR;
int idx = wide ? k - NSTR : k;
int rc, e;
(void)rc;
double r = 0;
long used = -1;
errno = 0;
if(!wide) { char* end = 0; CALL(rc, e, (r = f_strtod(NS[idx], &end), 0)); used = end ? (long)(end - NS[idx]) : -1; }
else { wchar_t* wend = 0; CALL(rc, e, (r = f_wcstod(WS[idx], &wend), 0)); used = wend ? (long)(wend - WS[idx]) : -1; }
char id[16];
snprintf(id, sizeof id, "%s.%d", SN[st], k);
snprintf(line, sizeof line, "fn=%s in=%d bits=0x%016llx errno=%d consumed=%ld signal=%d", wide ? "wcstod" : "strtod", idx, (unsigned long long)dbits(r), e, used, (int)guard_sig);
probe_case(id, wide ? "wcstod(table[in])" : "strtod(table[in])", guard_sig ? -1 : 0, e, line);
if(guard_sig) { _mm_setcsr(saved); probe_end(); return 0; }
}
if(st) _mm_setcsr(saved);
}
snprintf(line, sizeof line, "mxcsr_after=0x%08x (found 0x%08x)", _mm_getcsr(), saved);
probe_case("m.end", "MXCSR at the end", 0, 0, line);
probe_end();
return 0;
}output of run 1AI-assisted (Claude Code). |
|
No actionable comments were generated in the recent review. Walkthrough
Change: Other Merge Risk:
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this; the point below is optional.
What I ran
Reviewed head aa9f3232b5c55c84c7a60ae68e1c4e3bcb04fb9a. Read the prepared description, commit summary, diff, manifest, and the full text of the sole changed file. This is a documentation-only change; I ran no tests or builds. A repo_read.py search call for source context failed because the reader could not write its log in the read-only workspace.
Results
| Check | Result | Note |
|---|---|---|
| Changed file review | passed | Sole changed file fully read |
| Source context | not run | Reader log write was denied |
| Tests and builds | not run | Documentation-only change |
Negative control
Not applicable; this change adds documentation and does not change code or tests.
Findings
Blocking
None.
Non-blocking
- The console measurements and host comparison are described in the PR body, but their probe output is not among the reviewed artifacts. Consider linking or attaching that evidence for readers to check the detailed claims. The new entry is at
docs/dev/debt/changes/fix-libc-strtod-hex-subnormal-rounding.md:14(head permalink).
Sources
Not verified
- The implementation and callers behind the
strtodandwcstodstatements; the pinned reader could not complete its logged search in this read-only workspace. - Console probe output, host comparison output, and author-reported convention and debt-fold checks.
- Excluded files: none. Reviewed files:
docs/dev/debt/changes/fix-libc-strtod-hex-subnormal-rounding.md.
To get this to a good state
Nothing is required. Optional: link or attach the measurement output as noted above.
What
The technical debt entry for
strtodindocs/dev/debt/libc.md(line 229 onmain, from the fragmentfix-libc-strtod-hex-subnormal-rounding.md) said that the console'swcstodis unmeasured and that hexadecimal subnormalstrtodandwcstodmatch one title'slibc.prxonly. This change records what a PS5 on firmware 11.60 answered, in a homebrew payload process, forstrtodandwcstodoflibSceLibcInternal.sprxon 14 strings (eight decimal, six hexadecimal) with a subnormal, underflowing or normal result, and moves thewcstodstatement into an entry of its own. It does not change code or tests; it follows #28997 and #29001, which are merged.The console's
wcstodmatched itsstrtodline for line (result bits,errnoand the number of characters consumed) in both floating point states, and both matched this port for all 14 strings at MXCSR 0x1f80, the standard state: for example0x1p-1074gives bits 1 anderrno0,0x1p-1075gives 0 anderrno34,0x1.8p-1074gives 2 anderrno0,0x1p-1076gives 0 anderrno34. At MXCSR 0x9fc0, the value the probe process started with (flush to zero is set), three decimal subnormal strings (inputs 2, 3 and 5, 2.2250738585072011e-308, 4.9406564584124654e-324 and 2.4703282292062328e-324) return 0 witherrno34 for both functions. The comparison with this port is a small host program that callsstrtod_nid_postfixandwcstod_nid_postfixfromcore/libs/prx/libc/include/Api.hppon the same 14 strings (wide strings aschar16_t) and prints the same fields; all 28 lines (14 per function) agree with the console at 0x1f80; at 0x9fc0 the only differences are the three flush-to-zero strings of each function.The change is in the existing fragment
docs/dev/debt/changes/fix-libc-strtod-hex-subnormal-rounding.md(one fragment per entry; the entry is not yet folded intolibc.mdonmain). Thestrtodentry goes from 996 to 811 characters: thewcstodsentence leaves it and the hexadecimal sentence is kept as it was. A new entrywcstodunderadd Functional(543 characters, counted with the leading-, under the limit of 1000) keeps that sentence (wcstodparses throughstrtodand follows the rule of thestrtodentry, as thelibc.prxwcstodof eleven titles does, measured on Windows) and adds the console result: payload process, firmware 11.60, two runs, 2-bytewchar_t, prototypes assumed, a title process may differ, titles unmeasured.Not measured: a title process, other MXCSR states than 0x9fc0 and 0x1f80, directed rounding modes, strings other than these 14, and
wcstof. The prototypes in the probe are assumed.sizeof(wchar_t)was 2 in the probe build (case 2 of the output); the header comment of the probe still says 32-bit, which is what was assumed before the build.In the newest run folder of each of 56 titles (2026-12-05, 04:28 UTC), the import of
wcstodappears in 18 folders and that ofstrtodin 51, countingapp.registry.jsononly, with the same numbers for every registry file of the folder. An import is not a call; I have not shown that any title uses these two functions with a subnormal string, so this is not a title change.Tested
Measured on a PS5 with firmware 11.60 (
kernel_get_fw_version0x11600005), from a homebrew payload process, on 2026-12-05 at 05:01 UTC, two runs of one probe build (05:01:01 and 05:01:10 UTC). Both runs gave the same 67 cases andEND 67, no signal, and an exit value of 0; their output is identical except for the pid and the clock in thePROBEline (the console clock was about 1 h 43 min ahead of UTC). The probe source and the complete output of both runs are in the first comment.This is documentation only; no build or test was run for it. I ran
tools/check_conventions.py --base upstream/mainwith the title and this description andtools/debt_fold.py --checkon the merge of this branch (headaa9f3232b5c) withmainatec3c30e7a09don 2026-12-06 at about 11:47 UTC: it reports "All conventions checks passed", anddebt_fold.py --checkexits with 0.Overlap: counted on 2026-12-06 from the 1620 open pull requests (
mainat0afe7c9b09aaat the start; 944 of them had their patches scanned, from 11:06 to 11:44 UTC) with the fragmentdocs/dev/debt/changes/fix-libc-strtod-hex-subnormal-rounding.md,docs/dev/debt/libc.md, the filesStrings.cpp,DinkumwareInternals.cppandLibcxxSto.cppincore/libs/prx/libc/src/, the namesstrtodandwcstod, and the pathlibc: no open pull request changes the fragment or the entry atdocs/dev/debt/libc.md:229. 38 open pull requests changelibc.mdor one of the three source files or namestrtodorwcstodin a patch; the merge of this head with each of them was made withgit merge-tree: 29 are clean, and the other 9 already conflict withmainalone in as many files as with this head, so none because of this change. #28284 (fix(libc): honor strtod flush-to-zero with DAZ enabled, which changesStrings.cppandGuestStrtodSubnormal.cpp) merges cleanly with this head and does not change a debt file; it changes what this port does under DAZ, and the new sentence describes the state 0x1f80 (DAZ off) of this port and the console result at 0x9fc0, so it stays true if #28284 is merged first, which will be checked against the then currentStrings.cpp. The patches that namestrtodorwcstodare those of #28892, #14915 and #24669, which change calls or other entries and none of the two entries here; all merge cleanly with this head. The count was repeated from 11:44 to 11:46 UTC for the 53 of 1619 open pull requests that were updated since 11:05 UTC (24 patch-scanned): none shares a file or a name. 23 commits have been merged tomainsinced25135a8604, the base of this branch; none of them changedStrings.cpp,DinkumwareInternals.cpp,LibcxxSto.cpp,libc.mdor the fragment, and the merge of this head intomain(ec3c30e7a09d, 11:47 UTC) is clean (git merge-tree). This pull request does not depend on any of them (Depends on: none).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)Summary by CodeRabbit
strtoddocumentation with details onwcstodparsing, title-build comparisons, and console measurements under two MXCSR settings.