Fix LMDB sandbox EPERM on macOS#5036
Conversation
Use POSIX semaphores instead of SysV on Apple debug builds to avoid Seatbelt blocking mdb_env_open()
265fb87 to
dbb1fcf
Compare
Test Results for Commit dbb1fcfPull Request 5036: Results Test Case Results
Last updated: 2026-02-24 19:33:34 UTC |
There was a problem hiding this comment.
Pull request overview
This PR addresses an issue where LMDB fails to open on macOS due to the Seatbelt sandbox blocking SysV semaphores, causing mdb_env_open() to return EPERM errors. The fix enables POSIX semaphores instead by setting the MDB_USE_POSIX_SEM=1 compile definition for the LMDB library.
Changes:
- Added configuration to use POSIX semaphores for LMDB on macOS Debug builds to avoid Seatbelt sandbox restrictions
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # LMDB defaults to SysV semaphores on macOS, which are blocked by Seatbelt | ||
| # sandbox Use POSIX semaphores instead to avoid EPERM from mdb_env_open() | ||
| if(APPLE AND CMAKE_BUILD_TYPE STREQUAL "Debug") |
There was a problem hiding this comment.
The fix is only applied to Debug builds, but macOS Seatbelt sandbox restrictions that block SysV semaphores apply to all build types (Debug, Release, RelWithDebInfo, etc.). This means Release builds on macOS will still experience EPERM errors when calling mdb_env_open(). The condition should be changed to apply to all APPLE builds, not just Debug builds. Consider changing the condition to: if(APPLE)
| if(APPLE AND CMAKE_BUILD_TYPE STREQUAL "Debug") | |
| if(APPLE) |
| endif() | ||
|
|
||
| # LMDB defaults to SysV semaphores on macOS, which are blocked by Seatbelt | ||
| # sandbox Use POSIX semaphores instead to avoid EPERM from mdb_env_open() |
There was a problem hiding this comment.
Missing period at the end of the first sentence. The comment should read: "# sandbox." instead of "# sandbox Use"
| # sandbox Use POSIX semaphores instead to avoid EPERM from mdb_env_open() | |
| # sandbox. Use POSIX semaphores instead to avoid EPERM from mdb_env_open() |
macOS Seatbelt sandbox blocks SysV semaphores used by LMDB, causing mdb_env_open() to fail with EPERM. Use POSIX semaphores (MDB_USE_POSIX_SEM=1) instead. Only for Apple debug builds.