This is an automated email from the ASF dual-hosted git repository. raulcd pushed a commit to branch maint-25.0.x in repository https://gitbox.apache.org/repos/asf/arrow.git
commit fe141358b2783f2b85eaa982834aece0cb90c5b1 Author: Antoine Pitrou <[email protected]> AuthorDate: Tue Jul 21 11:03:07 2026 +0200 GH-50428: [C++] Better mimalloc configuration on macOS (#50549) ### Rationale for this change On macOS, two independently-linked mimalloc v3 instances built with default TLS settings can end up using the same hard-coded TLS slots and crash due to conflicting expectations. See upstream issue at https://github.com/microsoft/mimalloc/issues/1327 This can manifest when PyArrow is loaded side-by-side with another Python extension module that bundles its own instance of mimalloc. ### What changes are included in this PR? 1. Bump mimalloc to 3.4.1, for the availability of the required CMake option. 2. Configure macOS to use C thread-local variables for thread-local storage, avoiding conflicting accesses to hard-coded TLS slots on macOS. 3. Also, unrelatedly, make sure the default malloc is not overriden by our mimalloc build on macOS. ### Are these changes tested? By existing CI jobs. ### Are there any user-facing changes? No, just a bugfix. * GitHub Issue: #50428 Lead-authored-by: Antoine Pitrou <[email protected]> Co-authored-by: Antoine Pitrou <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]> --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 12 ++++++++++++ cpp/thirdparty/versions.txt | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index bcbf2e4645..1b5030c07d 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2565,7 +2565,11 @@ if(ARROW_MIMALLOC) "-DCMAKE_C_FLAGS=${MIMALLOC_C_FLAGS}" "-DCMAKE_INSTALL_PREFIX=${MIMALLOC_PREFIX}" -DMI_INSTALL_TOPLEVEL=ON + # Don't override default malloc -DMI_OVERRIDE=OFF + -DMI_OSX_INTERPOSE=OFF + -DMI_OSX_ZONE=OFF + # Allow usage through dlopen (i.e. when libarrow.so itself is dlopen'ed) -DMI_LOCAL_DYNAMIC_TLS=ON -DMI_BUILD_OBJECT=OFF -DMI_BUILD_SHARED=OFF @@ -2573,6 +2577,14 @@ if(ARROW_MIMALLOC) # GH-47229: Force mimalloc to generate armv8.0 binary -DMI_NO_OPT_ARCH=ON) + if(APPLE) + list(APPEND + MIMALLOC_CMAKE_ARGS + # GH-50428: Make sure several mimalloc instances can cohabit in the same process + # (also https://github.com/microsoft/mimalloc/issues/1327#issuecomment-4964140817) + -DMI_TLS_MODEL_LOCAL=ON) + endif() + externalproject_add(mimalloc_ep ${EP_COMMON_OPTIONS} URL ${MIMALLOC_SOURCE_URL} diff --git a/cpp/thirdparty/versions.txt b/cpp/thirdparty/versions.txt index c6f4b01a71..ff05b6bbae 100644 --- a/cpp/thirdparty/versions.txt +++ b/cpp/thirdparty/versions.txt @@ -80,8 +80,8 @@ ARROW_JEMALLOC_BUILD_VERSION=5.3.0 ARROW_JEMALLOC_BUILD_SHA256_CHECKSUM=2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa ARROW_LZ4_BUILD_VERSION=v1.10.0 ARROW_LZ4_BUILD_SHA256_CHECKSUM=537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b -ARROW_MIMALLOC_BUILD_VERSION=v3.3.1 -ARROW_MIMALLOC_BUILD_SHA256_CHECKSUM=42c16914168ac6741eeb407e83b93a12b2b7ee25a7e14e6b4807fab8b577a540 +ARROW_MIMALLOC_BUILD_VERSION=v3.4.1 +ARROW_MIMALLOC_BUILD_SHA256_CHECKSUM=37107a52c16baa80c5f74861dddda7b27bb9949e41a6637691867a94c88ca446 ARROW_NLOHMANN_JSON_BUILD_VERSION=v3.12.0 ARROW_NLOHMANN_JSON_BUILD_SHA256_CHECKSUM=4b92eb0c06d10683f7447ce9406cb97cd4b453be18d7279320f7b2f025c10187 ARROW_OPENTELEMETRY_BUILD_VERSION=v1.21.0
