Skip to content

systemError(boost::system::errc::X) reads errno values as Win32 codes on Windows #19745

Description

@kevinushey

Summary

systemError(boost::system::errc::X, location) has no overload for boost's errc_t, so it binds to systemError(int, ...) and builds a system_category() code. On Windows that category holds Win32 codes, so the errno value is read as a Win32 error code and the message is Win32's text for that number. Some values land on a matching Win32 code by coincidence (ENOENT and ERROR_FILE_NOT_FOUND are both 2); others don't. errc::is_a_directory (21) is ERROR_NOT_READY, so loadhistory() of a directory reported "The device is not ready". #19689 fixes that call, and the missing-file call beside it, by passing std::make_error_code(std::errc::X).

git grep 'systemError(boost::system::errc::' -- src/cpp finds 365 such calls.

Possible fix

Add a systemError() overload for boost::system::errc::errc_t that builds the code in generic_category(), as std::make_error_code(std::errc::X) does, so every one of these errors gets the errc's own message on every platform.

What to watch for

  • Comparisons. 11 checks compare against a reference built the same way (error == systemError(boost::system::errc::X, ErrorLocation()): FileLock::isNoLockAvailable, SocketUtils.hpp, PosixSystem.cpp, ...), as does POSIX isNotFoundError(). The overload would move those references to the generic category too. core::Error::operator== compares category names (Error comparisons match on error category name, so system- and generic-category codes never compare equal #18946), so they would stop matching the system-category errors from systemError(errno, ...) and LAST_SYSTEM_ERROR() on every platform, not just Windows. The overload needs Error comparisons match on error category name, so system- and generic-category codes never compare equal #18946's equivalence comparison first, or those checks need converting.
  • Windows not-found checks. isNotFoundError() compares against windows_error::file_not_found (system category, 2). An error built from systemError(errc::no_such_file_or_directory) matches it today only because both are 2, and would stop matching in the generic category.
  • Message text. MSVC's generic messages are lower case ("no such file or directory"), so user-facing text changes on Windows. Tests that match the Win32 text would need updating.

Activity

  1. self-assigned this
    on Nov 20, 2026
  2. added theissue type on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions