From e006a65aac7d3b5469eb199de2d5a7b29d8c8c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 2 Jan 2026 09:53:37 +0100 Subject: [PATCH] FreeBSD support for _POSIX_THREAD_PROCESS_SHARED is incomplete and buggy, avoid it. --- .github/workflows/ci.yml | 4 ---- include/boost/interprocess/detail/workaround.hpp | 8 ++++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efde576..bb4ce1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -927,10 +927,6 @@ jobs: then echo "Executing: sudo pkg git bash python3 curl" sudo pkg install -y git bash python3 curl - # Enable persistent umtx for vnode-backed shared memory synchronization - # This is needed for process-shared pthread mutexes in memory-mapped files - echo "Setting kern.ipc.umtx_vnode_persistent=1" - sudo sysctl kern.ipc.umtx_vnode_persistent=1 fi if [ "${{matrix.vm}}" == "openbsd" ] then diff --git a/include/boost/interprocess/detail/workaround.hpp b/include/boost/interprocess/detail/workaround.hpp index c064142..f3ce418 100644 --- a/include/boost/interprocess/detail/workaround.hpp +++ b/include/boost/interprocess/detail/workaround.hpp @@ -65,6 +65,14 @@ //https://opensource.apple.com/source/libpthread/libpthread-301.30.1/src/pthread_cond.c.auto.html //in method pthread_cond_wait #define BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED + #elif defined(__FreeBSD__) + //The FreeBSD implementation is not workable for Interprocess as data structures + //hold raw pointers and even "kern.ipc.umtx_vnode_persistent" does not solve this issue + //because de vnode will be recycled anyway since it is only useful when: + // - Multiple processes have the file mapped **simultaneously** + // - The kernel needs to coordinate their wait queues + //See (https://man.freebsd.org/cgi/man.cgi?query=libthr) for details + #define BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED #endif //If buggy _POSIX_THREAD_PROCESS_SHARED is detected avoid using it