Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile-dev-downloaded.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ COPY docker/build-gstreamer/download /download

RUN ["/download"]

COPY docker/build-gstreamer/fake_mallinfo.c /fake_mallinfo.c
COPY docker/build-gstreamer/compile /compile
COPY docker/build-gstreamer/patch /compile-patch
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ Stable released have 2 tags:
* regular like `1.18.1` that is a latest build of that upstream release
* stable reference with one more number after regular `major.minor.patch` that starts with 0 and is incremented if there are multiple builds for the same upstream stable version (like `1.18.1.0`)

## Chromium MemoryInfra SIGILL workaround

glibc's deprecated `mallinfo()` returns `int` fields that overflow once heap addresses exceed 2 GiB. Chromium's MemoryInfra collector still calls it and crashes with SIGILL as soon as a long-running CEF process grows its heap past that threshold. See [chromiumembedded/cef#3963](https://github.com/chromiumembedded/cef/issues/3963).

Image bundles `/usr/lib/libfakemallinfo.so`, a tiny shared library that overrides `mallinfo()` with a stub returning a zeroed `struct mallinfo`. Preload it via `LD_PRELOAD` when starting your binary. In a Dockerfile:

```dockerfile
ENV LD_PRELOAD=/usr/lib/libfakemallinfo.so
```

The shim is a no-op for callers that don't use `mallinfo()`, so it's safe to leave preloaded for the whole process tree.

## Contribution
Feel free to create issues and send pull requests, they are highly appreciated!

Expand Down
10 changes: 10 additions & 0 deletions docker/build-gstreamer/compile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ set -e

source $HOME/.cargo/env

# Build LD_PRELOAD shim that replaces glibc's deprecated mallinfo() with a
# stub returning a zeroed struct. Works around a Chromium bug where
# MemoryInfra crashes with SIGILL once heap addresses exceed 2 GiB, because
# mallinfo()'s int fields overflow. Install both into the live filesystem and
# into /compiled-binaries so it propagates to dev/prod images via COPY --from=0.
# @see https://github.com/chromiumembedded/cef/issues/3963
gcc -O2 -Wall -Wextra -fPIC -shared -o /usr/lib/libfakemallinfo.so /fake_mallinfo.c
mkdir -p /compiled-binaries/usr/lib
cp /usr/lib/libfakemallinfo.so /compiled-binaries/usr/lib/libfakemallinfo.so
Comment thread
mchelnokov marked this conversation as resolved.

pushd gstreamer
# TODO: Hack: `-D gupnp=disabled` is for libnice, because libgupnp-igd causes memory leaks
# msdk=enabled is for gst-plugings-bad to include msdk elements
Expand Down
12 changes: 12 additions & 0 deletions docker/build-gstreamer/fake_mallinfo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// LD_PRELOAD shim that replaces glibc's deprecated mallinfo() with a stub
// returning a zeroed struct. Works around a Chromium bug where MemoryInfra
// crashes with SIGILL once heap addresses exceed 2 GiB, because mallinfo()'s
// int fields overflow.
// @see https://github.com/chromiumembedded/cef/issues/3963

#include <malloc.h>

struct mallinfo mallinfo(void) {
struct mallinfo m = {0};
return m;
}
Comment thread
mchelnokov marked this conversation as resolved.
Loading