Skip to content

fix(mem): no glibc malloc_trim; the static Linux release links again - #2212

Merged
DeusData merged 1 commit into
mainfrom
fix/static-linux-no-malloc-trim
Sep 15, 2026
Merged

DeusData merged 1 commit into
mainfrom
fix/static-linux-no-malloc-trim

Conversation

@DeusData

Copy link
Copy Markdown
Owner

The v0.10.9 release run 34948714902 failed both Linux portable builds: malloc/free/realloc defined twice, mimalloc's override and libc.a(malloc.o). The only new reference into glibc's malloc object was malloc_trim(0) in cbm_mem_release_to_os (7b77fd4); on Linux mimalloc owns malloc, so the call trimmed nothing. Removed with its include. The static build (scripts/build.sh CC=gcc CXX=g++ STATIC=1) in the local arm64 container reproduced the failure exactly and links after the change, the binary fully static; mem and parallel suites green.

The v0.10.9 release run (34948714902) failed in both Linux portable
builds: the static link found malloc, free, realloc, calloc, memalign,
valloc, pvalloc and posix_memalign defined twice, once by mimalloc's
override and once by libc.a(malloc.o). Nothing in the build flags had
changed since v0.10.8; what changed was one call. cbm_mem_release_to_os
called glibc's malloc_trim(0), and that symbol lives only in malloc.o, so
the reference pulled the whole object into the link next to mimalloc's
definitions. Dynamic builds never noticed: interposition resolves the
duplicates at load time, which is why the whole test matrix was green.

The call was pointless where it broke things: on Linux and Windows the
override routes every malloc to mimalloc, so glibc's heap holds nothing
to trim and mi_collect(true) is the release. The branch and its include
are gone; macOS keeps its pressure-relief call, since the system heap
still serves everything outside the core there.

Verification: the static build (scripts/build.sh CC=gcc CXX=g++
STATIC=1) in the local arm64 container reproduced the CI failure exactly
before the change and links after it, the binary reporting its version;
mem and parallel suites green on the host.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData
DeusData merged commit 8972ea6 into main Sep 15, 2026
34 of 35 checks passed
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