#36038 util: remove usage of `strerror_r`

ReviewabilityReviewsAgreementSize
#36038 fanquake util: remove usage of `strerror_r`Waiting on author0Crickets9 + 1 tests
  • Simplify non-Windows system error formatting and remove platform-specific buffer branching
  • Eliminate custom build-time checks needed to handle GNU versus POSIX error string variants
  • Ready to review
  • No review verdicts recorded
  • No substantive approvals or rejections yet
  • Suggested postponing until PR 36042 due to missing changes in GCC 12 libstdc++ (hebasto)
  • Suggested adjusting header includes between Windows and other platforms (hebasto)
  • 9 lines added or modified outside tests
  • 1 lines added or modified in tests
  • 33 lines removed in total
  • 5 files, 1 commits
Utilities (logging, arguments, libraries)#47 of 59
P3 · cleanup
  • P3 because it is an internal refactoring that simplifies error formatting without user-facing impact
  • Reduces maintenance overhead by delegating platform differences to the standard library
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Replaces platform-specific handling of GNU and POSIX `strerror_r` in `SysErrorString` on non-Windows systems with `std::system_category().message(err)`. Removes the `STRERROR_R_CHAR_P` CMake introspection check and config macro while keeping the Windows `strerror_s` branch intact.

Problem: Handling both GNU and POSIX signatures of `strerror_r` required custom buffer management, preprocessor branching, and a CMake compile check. Standard C++ already encapsulates this platform-specific logic via `std::system_category()`.

Evidence of importance:

  • PR description notes that `std::system_category().message(err)` on non-Windows internally dispatches to `strerror_r` and handles unknown errors, citing LLVM libc++ implementation

Risk of a mistake: low (build). A standard library discrepancy on a non-Windows platform could format unexpected error descriptions into diagnostic logs.

Changed since the previous assessment: The PR retains the Windows `strerror_s` branch and its lint exception instead of replacing it with `std::system_category()`, applying the standard library replacement only to non-Windows platforms.

Reviewability

Paused · Waiting on author

Open objections from hebasto with no author reply for 13 days; review would repeat what has been asked.

Waiting on (from the thread read):

  • author: fanquake to respond to hebasto's review regarding PR 36042 and header includes 2026-10-19

Agreement

Crickets

no substantive comment either way

Thread notes: Added fanquake's reply resolving rc:4165606953. Recorded hebasto's suggestions on postponing until PR 36042 and adjusting header includes.

Objections, suggestions, and questions:

ReviewerTypeHarm, request, or questionStatusMust beAuthor repliedQuote
hebasto (member)question, safetyIs it safe to remove the Windows-specific code?answered · fix pushed · fanquake noted Windows-related changes were removed; previously answered by maflckoansweredyes2026-10-02: 'Is it safe to remove this Windows-specific code?'
Status from: 2026-10-19: fanquake: 'Really removed any Windows related changes.'
hebasto (member)suggestion, approachPostpone this change until #36042 because GCC 12 libstdc++ lacks the corresponding change.openansweredno2026-10-19: 'Does it make sense to postpone this change until https://github.com/bitcoin/bitcoin/pull/36042?'
hebasto (member)suggestion, maintenanceInclude <cstring> on Windows and keep <system_error> only on non-Windows.openansweredno2026-10-19: '+#include <cstring> ... +#include <system_error>'

Participants:

  • maflcko (member, neutral, 2 statements 2026-08-20 to 2026-10-13): suggested a formatting nit on doxygen comment indentation and referenced an earlier comment on syserror
  • hebasto (member, question, 2 statements 2026-10-02 to 2026-10-19): asked about Windows-specific code safety and whether to postpone until #36042 due to GCC 12

Files

2 lines under test/bench/ci.

  • src/util/syserror.cpp +7/-13
  • cmake/introspection.cmake +0/-12
  • src/util/syserror.h +2/-4
  • cmake/bitcoin-build-config.h.in +0/-3
  • test/lint/lint-locale-dependence.py +1/-1

Card

The short text the ranking pass compares across PRs.

Replaces POSIX and GNU variants of strerror_r in SysErrorString on non-Windows platforms with standard C++ std::system_category().message(err), while keeping strerror_s on Windows. This eliminates custom buffer logic and the STRERROR_R_CHAR_P CMake introspection check. It is an internal cleanup with no user-visible behavior change or external dependencies.

Data

dossier JSON · extract JSON · model ledger, generated 2026-10-21T01:17, confidence high, input hash 961c5de9d21a9a3d
thread read through 2026-10-19 (7 statements), head cd5280d0eb
labels: Utils/log/libs

Categories

Utilities (logging, arguments, libraries)

P3 · cleanup

Replacing POSIX and GNU strerror_r buffer handling with std::system_category().message(err) cleanly simplifies system error formatting across non-Windows platforms. It removes preprocessor branching and custom buffer logic in favor of the standard library, but is an internal refactoring that can be safely deferred.

Membership: Matches Utils/log/libs label and modifies src/util/syserror.{cpp,h}.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 0