Skip to content

Bundle libfakemallinfo.so to work around mallinfo() SIGILL on >2 GiB heaps - COR-1118#82

Merged
mchelnokov merged 2 commits into
masterfrom
libfakemallinfo
May 7, 2026
Merged

Bundle libfakemallinfo.so to work around mallinfo() SIGILL on >2 GiB heaps - COR-1118#82
mchelnokov merged 2 commits into
masterfrom
libfakemallinfo

Conversation

@mchelnokov
Copy link
Copy Markdown
Contributor

Bundle libfakemallinfo.so LD_PRELOAD shim in published images

glibc's deprecated mallinfo() returns int fields that overflow once heap addresses exceed 2 GiB, causing SIGILL in callers that still use it. Ship a tiny shared library that returns a zeroed struct mallinfo, ready to be loaded via LD_PRELOAD=libfakemallinfo.so.

Build it from docker/build-gstreamer/fake_mallinfo.c at the top of the existing /compile script and install to both /usr/lib/ (live) and /compiled-binaries/usr/lib/. Routing through /compiled-binaries piggybacks on the existing COPY --from=0 steps, so the .so lands in all four published variants (latest-dev-with-source, latest-dev, latest-prod, latest-prod-dbg) with no changes to dev-dependencies or prod-base.

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@mchelnokov
Copy link
Copy Markdown
Contributor Author

@claude review once

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request bundles a small LD_PRELOAD shared library (libfakemallinfo.so) into the published Ubuntu 22.04-based GStreamer images to work around crashes in third-party callers still using glibc’s deprecated mallinfo() once heaps exceed ~2 GiB.

Changes:

  • Add a new C source file implementing a mallinfo() shim returning a zeroed struct mallinfo.
  • Build libfakemallinfo.so during the existing /compile step and copy it into /compiled-binaries so it propagates to all image variants via existing COPY --from=0 behavior.
  • Ensure the build stage has access to the shim source by copying it into the dev-downloaded stage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Dockerfile-dev-downloaded.in Copies fake_mallinfo.c into the build stage so /compile can build the shim.
docker/build-gstreamer/fake_mallinfo.c Introduces the mallinfo() interposer implementation.
docker/build-gstreamer/compile Builds and installs libfakemallinfo.so into both the live filesystem and /compiled-binaries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docker/build-gstreamer/fake_mallinfo.c
Comment thread docker/build-gstreamer/compile
…heaps

CEF/Chromium's MemoryInfra calls glibc's deprecated mallinfo(), whose return struct uses `int` fields. Once heap addresses exceed 2 GiB the arithmetic inside glibc overflows and triggers a SIGILL, crashing the process at random. See chromiumembedded/cef#3963 ("linux: Random crash due to MemoryInfra"): chromiumembedded/cef#3963

Build a tiny LD_PRELOAD shim that overrides mallinfo() to return a zeroed struct, and stage it into /compiled-binaries/usr/lib so the existing `COPY --from=0 /compiled-binaries /` steps propagate it into all four published image variants. Consumers opt in by setting LD_PRELOAD=/usr/lib/libfakemallinfo.so for processes that load CEF.
@ArmorDarks ArmorDarks force-pushed the libfakemallinfo branch 4 times, most recently from 6cc6736 to de812cc Compare May 7, 2026 11:00
@ArmorDarks
Copy link
Copy Markdown
Member

Added some additional docs. good to go

@mchelnokov mchelnokov merged commit 1ef0196 into master May 7, 2026
4 checks passed
@mchelnokov mchelnokov deleted the libfakemallinfo branch May 7, 2026 12:07
@ArmorDarks ArmorDarks changed the title Bundle libfakemallinfo.so to work around mallinfo() SIGILL on >2 GiB heaps Bundle libfakemallinfo.so to work around mallinfo() SIGILL on >2 GiB heaps - COR-1118 May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants