Skip to content

Conversation

@Manas103
Copy link

@Manas103 Manas103 commented Jan 8, 2026

Rationale for this change

The __map_mman_error() function in cpp/src/arrow/io/mman.h was not properly mapping Windows error codes to POSIX errno values. The function contained a TODO comment and returned raw Windows error codes (DWORD values like 2, 5, 6, 112) directly instead of converting them to POSIX errno values (like ENOENT, EACCES, EBADF, ENOSPC). This broke errno-based error handling in memory mapping operations on Windows, as code expecting POSIX errno values would receive raw Windows error codes instead.

What changes are included in this PR?

  • Implemented proper Windows error code to POSIX errno mapping in __map_mman_error() function
  • Maps 14 common memory mapping errors (ERROR_FILE_NOT_FOUND, ERROR_ACCESS_DENIED, ERROR_NOT_ENOUGH_MEMORY, etc.) to appropriate POSIX errno values
  • Mapping matches Arrow's existing WinErrorToErrno() conventions for consistency
  • Maintains behavioral compatibility by using the deferr parameter (EPERM default) for unmapped errors
  • Added comprehensive Windows-gated unit tests in file_test.cc covering all mapped errors, zero case, and fallback behavior

Are these changes tested?

Yes. Added TestMmanErrorMapping.MapCommonErrors test covering all mapped error codes, zero error code case, and fallback behavior. Tests are Windows-gated (#ifdef _WIN32) and will run on Windows CI.

Are there any user-facing changes?

No.

GitHub Issue: #48793

Implement proper Windows error code to POSIX errno mapping in
__map_mman_error() function. Maps common memory mapping errors
(ERROR_FILE_NOT_FOUND, ERROR_ACCESS_DENIED, etc.) to appropriate
errno values, matching Arrow's WinErrorToErrno() conventions.

- Map 14 common mmap errors to POSIX errno values
- Maintain behavioral compatibility with deferr parameter
- Add comprehensive Windows-gated unit tests
- Fix broken behavior (was returning raw error codes)
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

See also:

Copy link
Member

@raulcd raulcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR, could you open an issue and follow our PR description and naming convention guidelines?

@Manas103 Manas103 changed the title [C++] Fix Windows mmap error code mapping in mman.h GH-48788: [C++] Fix Windows mmap error code mapping in mman.h Jan 8, 2026
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

⚠️ GitHub issue #48788 has been automatically assigned in GitHub to PR creator.

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants