Repository navigation
Conversation
|
|
7f822e3 to
af24a15
Compare
580b288 to
e49e9ab
Compare
|
Windows test of head
Not checked: that the test fails without the change, Linux, a title run. AI-assisted (Claude Code). |
|
What shows that the console sets |
|
I do not have console evidence that the Dinkumware conversion functions set EINVAL when no digits convert; the current evidence is only FreeBSD strtol behavior. The current diff also changes the shared parser path so atoi inherits that errno, which the existing guest_atoi regression catches. I agree this PR is not ready to merge until that regression is fixed and the console-side behavior is supported by evidence or the change is narrowed. |
adriadam10
left a comment
There was a problem hiding this comment.
guest_atoifails with this merged onto currentmain(ctest -R guest_atoi; the other three PR tests pass): since #3687atoigoes throughstrtol, so the newerrno = EINVALreaches it.atoimust not seterrno; keep that path out ofParseGuestInteger(e.g. save/restore errno inatoi, or a variant without the errno write).- No evidence that the console sets
EINVALwhen nothing converts: the FreeBSD 11.4strtolcomparison does not cover the Dinkumware_Stoul/_Stoullentry points. Please add a console result or a title that depends on it (or narrow the change to what is shown), and say in TechnicalDebt which reference this follows.
Happy to re-review once guest_atoi passes and the evidence is added.
|
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.
|
e49e9ab to
e3724ab
Compare
|
Updated and rebased this PR on current |
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for fixing atoi; guest_atoi and the other three tests pass here merged onto main (Linux, scoped build + ctest).
- The premise is contradicted by the console. Disassembling
strtol(NIDmXlxhmLNMPg) in a title's shippedlibc.prx: the wrapper passes a local error cell to the inner parser and copies it toerrnoonly if non-zero. When no digits convert, the inner parser returns 0 with*endptr = strand leaves the cell at 0. The only places it writes the cell areERANGE(0x22) andEINVAL(0x16) for a base above 36. Soerrnostays unchanged for"","abc", whitespace-only, sign-only. FreeBSD 11.4strtolis not what the console runs. core/libs/prx/libc/include/General.hpp:32: dropif (end == str) errno = EINVAL;. The expected22for no-conversion cases inGuestMath.cpp:355-356,410-411,GuestWideStrings.cpp:162-172andGuestWideConversion.cpp:73-74should go back to unchangederrno(0in the tests, as before).- The invalid-base check (
General.hpp:24-28) matches the console for base > 36 (EINVAL,endptr = str). Base 1 is not confirmed by the disassembly; if you keep it, please say where it comes from. This part could stay as the PR's actual change, with the#3931reference adjusted since the issue's claim does not hold for the console.
|
Tested on Linux x86-64 (Ubuntu 24.04 in a Colima VM with Rosetta on Apple M4, GCC 13.3), this PR (
AI-assisted: yes (Claude Code). |
FreeBSD strtol, strtoul, strtoll, strtoull, strtoimax, strtoumax and the wcsto* variants set errno to EINVAL when no digits are converted. The host functions leave errno untouched, so guests testing errno after parsing text such as "abc" or "" saw 0.
e3724ab to
e34a49c
Compare
|
I narrowed the PR to invalid-base handling and rebased all three commits onto current main |
|
Follow-up on final head |
|
The latest head |
|
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line. |
What
This rebased carry preserves Hussein Kadhim's original implementation commit and author attribution, but narrows its behavior to invalid-base handling. A collaborator's console
strtoldisassembly report in the review discussion shows that no-digit conversions return zero, leaveendptrat the input start, and preserveerrno; this PR now keeps that behavior. The same report showsEINVALfor a base above 36. The parser validates bases against the ISO C set{0, 2..36}before calling the host CRT, so invalid values return zero,EINVAL, and the original input pointer consistently instead of reaching host-specific invalid-parameter behavior.The shared validation also applies to the narrow and wide integer conversion wrappers. Dinkumware
_Stouland_Stoullretain their previous behavior and are not routed through the new helper. Console behavior for base 1, negative bases, and the wide conversion family is not independently verified and is recorded in technical debt.Tested
Linux x86-64, GCC 12.2, Release, current
maindacd78525:libcandguest_atoi_tests,guest_math_tests,guest_wide_conversion_tests, andguest_wide_string_tests.guest_atoi,guest_math,guest_wide_conversion, andguest_wide_stringspassed (4/4).tools/check_conventions.py --base upstream/mainandgit diff --checkpassed.Checklist
main; no open PR found for invalid-base behavior