#36038 util: remove usage of `strerror_r`
| Reviewability | Reviews | Agreement | Size | ||||
|---|---|---|---|---|---|---|---|
| #36038 util: remove usage of `strerror_r` | Waiting on author | 0 | Crickets | 9 + 1 tests | |||
|
|
|
|
| |||
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:
| Reviewer | Type | Harm, request, or question | Status | Must be | Author replied | Quote |
|---|---|---|---|---|---|---|
| hebasto (member) | question, safety | Is it safe to remove the Windows-specific code? | answered · fix pushed · fanquake noted Windows-related changes were removed; previously answered by maflcko | answered | yes | 2026-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, approach | Postpone this change until #36042 because GCC 12 libstdc++ lacks the corresponding change. | open | answered | no | 2026-10-19: 'Does it make sense to postpone this change until https://github.com/bitcoin/bitcoin/pull/36042?' |
| hebasto (member) | suggestion, maintenance | Include <cstring> on Windows and keep <system_error> only on non-Windows. | open | answered | no | 2026-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
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