Skip to content

fix(libc): use FreeBSD's strerror message texts - #2727

Closed
husseinkad wants to merge 2 commits into
boykopovar:mainfrom
husseinkad:fix/libc-strerror-texts
Closed

husseinkad wants to merge 2 commits into
boykopovar:mainfrom
husseinkad:fix/libc-strerror-texts

Conversation

@husseinkad

@husseinkad husseinkad commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What

The guest strerror and strerror_r returned message texts that differ from FreeBSD's lib/libc/gen/errlst.c for 25 of the 97 errno values 0 to 96 (the numbering was already right). Examples: 0 "No error" (FreeBSD: "No error: 0"), 30 "Read-only filesystem" ("Read-only file system"), 47 "Address family not supported" ("Address family not supported by protocol family"), 62 "Too many symbolic links" ("Too many levels of symbolic links"), 69 "Disk quota exceeded" ("Disc quota exceeded"), 70 "Stale file handle" ("Stale NFS file handle"), 84 "Value too large" ("Value too large to be stored in data type"). The other differing entries are 49, 52, 53, 58, 59, 71 to 76, 79, 81, 83, 86, 91, 93 and 94. A title or library that prints or compares these texts (the guest syslog %m goes through strerror_r) saw a different string than on the console.

The message table in Errors.cpp is now the one in FreeBSD's releng/11.4 errlst.c (the repo pins the FreeBSD 11 ABI; the texts for 0 to 96 are identical in releng/9.0, 10, 11.4 and 12, which differ only in how many entries the table has). The unknown-error text (Unknown error: N), the errno handling and the buffer logic are unchanged.

Tested

Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release:

  • guest_errors now checks strerror_r and strerror against a 97-entry FreeBSD table for every errno from 0 to 96, and the exact unknown-error texts for -1, 97, INT_MAX and INT_MIN; it fails without the change (exit 0xc0000409) and passes with it. ctest -R guest_errors passes.
  • Outside the repo, two independent scripts that parse sys_errlist[] from the FreeBSD 11.4 source (and from 9.3) against the built exports: all 97 texts match in both Errors.cpp and the test table (the 25 changed ones, and the other 72 unchanged), unknown errnos from -5 to 120 and INT_MIN/INT_MAX give Unknown error: N, strerror_r truncation and NUL termination match a model of FreeBSD's for 1032 (errno, size) calls with no write outside the buffer, and 8 threads calling strerror and strerror_r for 2 seconds (16 million calls) never saw a torn string.
  • A known difference left as is (it is the subject of the closed fix(libc): preserve invalid strerror error precedence #2057): for an unknown errnum and a buffer that is too small, strerror_r returns ERANGE where FreeBSD returns EINVAL.
  • tools/check_conventions.py --base origin/main passes; tools/pr_overlap.py --branch reports no overlap.
  • Linux not run (the table is shared, not platform specific).

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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

Twenty-five of the ninety-seven errno messages differed from FreeBSD releng/11.4 lib/libc/gen/errlst.c (for example errno 0, 30, 47, 62, 70 and 84).
@github-actions github-actions Bot added the intake paused Closed while PR intake is limited to authors with at least 10 PRs merged into main label Oct 10, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

intake paused Closed while PR intake is limited to authors with at least 10 PRs merged into main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant