Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
Vendored mimalloc: source pin and local patches
Source pin
- Upstream: https://github.com/microsoft/mimalloc
- Tag:
v3.5.3(annotated tag objectdeac3dcf5f0614884013d411a5c07e16bec96c9f) - Commit:
d4881d338125e1cb7c47ba4cfb398d6f7c0c8d45(treefbc4e8f72287d127c079ada5ede870b7d63e55f5) - Vendored:
LICENSE, every file underinclude/and every file undersrc/. Nothing else (no build files, tests or docs).
v3.5.3 is upstream's latest published release at the time of the pin
(GitHub release of 2026-09-17, on the main3 branch).
v3.5.3 contains upstream commit b2226c195fe884223f6d6f68ea52df476e57e5c2
(mimalloc #1341, first released in v3.4.4): free(NULL) must work before the
allocator is initialized. With 3.3.2's release build, glibc 2.44's
newlocale() freed NULL during libstdc++ start-up, before mimalloc's
constructor, and every Linux binary died with SIGSEGV (reported with a
reproduction by Felix Rath in #2562). The preinit fixture in
tests/test_prod_allocator_contract.sh pins it.
Verifying the vendored bytes
Every vendored file is byte-identical to the tag except the two hunks below. Re-check from a fresh bare clone (nothing in it is built or run):
git clone --bare https://github.com/microsoft/mimalloc.git /tmp/mimalloc.git
git --git-dir=/tmp/mimalloc.git rev-parse 'v3.5.3^{commit}' # d4881d33...
for f in $(git --git-dir=/tmp/mimalloc.git ls-tree -r --name-only v3.5.3 -- LICENSE include src); do
[ "$(git --git-dir=/tmp/mimalloc.git rev-parse "v3.5.3:$f")" = \
"$(git hash-object "vendored/mimalloc/$f")" ] || echo "differs: $f"
done
The expected output is exactly the two files named below, and
vendored/mimalloc/include plus vendored/mimalloc/src must hold no file the
tag lacks.
Local patches (reapply on every refresh)
Each patch is pinned by a check that fails when the patch is dropped.
1. macOS decommit always recommits: src/prim/unix/prim.c
In _mi_prim_decommit, macOS takes the recommit path that upstream reserves for
MI_DEBUG / MI_SECURE>2 builds, so a purged range is not re-accounted as a
whole by MADV_FREE_REUSE when the arena reuses it. This cut the indexer's peak
phys_footprint substantially (measurements in the inline comment and in commit
63fb7b3d; re-measured on v3.5.3 when this pin was taken). Linux and Windows keep
upstream's behaviour.
Pinned by: the decommit fixture in tests/test_prod_allocator_contract.sh
(needs_recommit must be true on macOS and upstream's false elsewhere).
2. Comment wording: src/prim/osx/alloc-override-zone.c
Comment only, no code change: "crash in fork()." reads "crash while forking.".
scripts/security-vendored.sh rejects call spellings such as fork( anywhere
in vendored C, comments included, so the upstream sentence fails that gate.
(Wording first proposed in #2562.)
Pinned by: scripts/security-vendored.sh itself, which reports the pristine
upstream line as a blocked subprocess call.
Build configuration
Makefile.cbm compiles the production object with -DMI_PROFILE=0, which
leaves out mimalloc's allocation-sampling profiler (on by default since 3.5.2)
and its sample countdown on the allocation path. Pinned by: the banner fixture
in tests/test_prod_allocator_contract.sh (a profiling build prints a
profiling line). The test build keeps upstream's default.
Dropped patches
- Reproducible version banner (
src/options.c, carried from 1f674c80 up to 3.4.4): upstream removed__DATE__/__TIME__from the banner in v3.4.5 (mimalloc #1355). The banner fixture intests/test_prod_allocator_contract.shstill asserts that the first line is exactlyvX.Y.Zwith no build clock, so a future refresh cannot bring it back unnoticed.
Refresh procedure
- Replace
LICENSE,include/andsrc/with the new tag's files, deleting files the tag no longer has, and verify the staged tree against the tag before patching. - Reapply the patches above, or drop the ones upstream has absorbed (and move them to "Dropped patches" with the upstream reference).
- Update the pin in this file and
versionInfoinscripts/ci/generate-sbom.py, then runscripts/security-vendored.sh --update. - After
make -f Makefile.cbm cbm, runbash tests/test_prod_allocator_contract.sh build/con Linux and macOS (scripts/test.shruns it on every CI leg), andscripts/security-vendored.sh.