Skip to content

Fix: mmap MAP_FAILED not handled correctly on POSIX#722

Open
DavIvek wants to merge 1 commit intounum-cloud:main-devfrom
DavIvek:fix/mmap-map-failed-check
Open

Fix: mmap MAP_FAILED not handled correctly on POSIX#722
DavIvek wants to merge 1 commit intounum-cloud:main-devfrom
DavIvek:fix/mmap-map-failed-check

Conversation

@DavIvek
Copy link

@DavIvek DavIvek commented Mar 2, 2026

Problem

On POSIX, mmap returns MAP_FAILED ((void*)-1) on failure, not NULL: https://man7.org/linux/man-pages/man2/mmap.2.html
Two call sites were incorrectly treating the return value as nullable:

  • index_plugins.hpp: allocate() cast mmap result directly to byte_t* without checking MAP_FAILED, returning a garbage pointer instead of nullptr
  • bench.cpp: persisted_matrix_gt checked == nullptr instead of == MAP_FAILED,
    silently passing on failure and proceeding with an invalid pointer

Fix

Both are fixed to check MAP_FAILED before casting.

@DavIvek DavIvek changed the base branch from main to main-dev March 2, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant