Repository navigation
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
Reviewed; the change checks out. I re-derived One coverage nit only: the two |
There was a problem hiding this comment.
The added boundary-state assertions address the coverage gap raised by @fogydes. I independently checked the recurrence and vectors in MinimalStandardNext, including the 0x7ffffffe/0xffffffff signed-state paths; the implementation and expected values are internally consistent. The debt entry also records the lock behavior difference and that the disassembly has not been measured on hardware. Validation: exact-head conventions and git diff --check pass; hosted relinker, registration, report, eligibility and labels checks pass. Product Linux/Windows jobs were skipped by path filters. I attempted a local exact-head configure, but it stopped before building because the SDL2 submodule is uninitialized and this host lacks XRandR support; no local runtime result is claimed. The author reports Windows libc suite 143/143 and the updated guest_math 3/3. This is generic behavior with Unblocks: none.
I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
|
Rebased onto |
d933925 to
e380d13
Compare
There was a problem hiding this comment.
I am withdrawing that hold as a review concern: current CONTRIBUTING.md sets the per-author cap based on merged-PR count and has no cap from 20 merged PRs; the author is well beyond that tier. I found no code issue in this head and am not asking for additional changes. I rechecked the exact patch: git diff --check and tools/check_conventions.py pass. The hosted register-context, relinker (Linux, Windows and macOS), ASan, write-watch, report, eligibility, conventions and labels checks pass; full Linux/Windows product builds are skipped by path filters. I also compiled and ran a small UBSan-enabled harness using the PR’s exact rand/rand_r implementation and current test vectors; it passed. A full project configure was blocked before compilation because the SDL2 submodule is absent and this host lacks XRandR support, so this is not a local guest_math run. The author reports the Windows libc and guest-math suites pass 3/3. The draft status is the author’s choice.
I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
|
@MarcZX10 thanks for rechecking it. I've marked this ready for review. |
|
Back to draft: @MarcZX10 clarified that the #5239 intake guidance is still active (#9688 (comment)). While the open queue is above 700, a PR should name a title shown to need the change on current |
|
I’ve noticed that asking you to hold this PR was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course. |
rand and rand_r both used FreeBSD's do_rand (Park and Miller on state % 0x7ffffffe + 1, minus one), so rand returned values up to 0x7ffffffd and rand(), rand_r() and every seeded sequence differed from the console. The libc.prx that titles ship (the same code in the copies of PPSA13934, PPSA07923 and PPSA05916, read from disassembly) uses two different generators: - rand steps a 64-bit state, initially 1, as state * 0x5851F42D4C957F2D + 1 and returns (state >> 32) & 0x3FFFFFFF, so its results stay at or below 0x3FFFFFFF. srand stores the seed zero-extended as that state. - rand_r is the minimal standard generator, state * 16807 modulo 2^31 - 1 on the signed 32-bit state (1 gives 16807, 282475249, 1622650073), and a zero state becomes 0x2AE1B767. guest_math now expects those results: the rand_r chain from 1, the zero and 0x7FFFFFFF states, rand after srand(1), srand(0) and srand(0xFFFFFFFF), and rand's range over 1000 calls. Its previous checks expected FreeBSD's values and rand matching rand_r. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e380d13 to
e6047b0
Compare
|
Runtime check of the rebased head e6047b0, adding to the disassembly reading. A scratch loader runs PPSA07923's decrypted The first five values match exactly in every case, both unseeded and after
On |
|
Two PS4 data points for this change. PS4 titles ship the same code. The and the state's initial value in the data segment is 1 in both. So the model here also covers PS4 titles, which load their bundled The console's system libc differs. A homebrew probe on a PS4 Pro (firmware 10.71), which has no bundled |
…system libc Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, both data points are useful.
AI-assisted: yes (Claude Code). |
What
rand,srandandrand_rnow follow thelibc.prxthat titles ship insce_module/. I read it from disassembly of the copies of PPSA13934, PPSA07923 and PPSA05916, which have the same code; I didn't measure on a console.On
main, bothrandandrand_ruse FreeBSD'sdo_rand(Park and Miller onstate % 0x7ffffffe + 1, minus one), so:randreturns values up to0x7ffffffdrand()matchesrand_r()from the same seedThe console uses two different generators.
rand(cpCOXWMgha0) andsrand(VPbJwTCgME0): a 64-bit LCGsrandstores its seed zero-extended (mov %edi,%eax; mov %rax,(state)).rand's results stay at or below0x3FFFFFFF. This is the part titles are most likely to notice: code that divides by its ownRAND_MAXcan get values above 1.0 onmain.rand_r(dW3xsu3EgFI): the minimal standard generatorstate * 16807(imul $0x41a7) modulo 2^31 − 1 on the signed 32-bit state. From 1 that gives 16807, 282475249, 1622650073 (MINSTD), where FreeBSD gives 33613.0x2AE1B767(mov $0x2ae1b767,%eax).The code is written from that arithmetic. The console's
randkeeps its state without a lock; this one keepsg_randLock. The libc debt file records both.Tested
Platform: Windows 11 (10.0.22621), WinLibs GCC 15.2.0 UCRT r7, Release.
guest_mathnow expects the console's results:rand_rchain from 10x7FFFFFFF,0x7FFFFFFEand0xFFFFFFFFstatesrandaftersrand(1),srand(0)andsrand(0xFFFFFFFF)rand's range over 1000 callsIts previous checks expected FreeBSD's values and
rand == rand_r. It passes, and so do the other random tests:guest_posix_random,guest_random_state,guest_random,guest_sandbox_random_word. The whole libc suite passes (143/143).Conventions:
tools/check_conventions.pypasses.Not tested: no title was run, and nothing was measured on a console.
random/srandomare not touched; fix(libc): seed random() and its default state as measured on a PS5 #8979 covers those.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)🤖 Generated with Claude Code