From c1ba04c9c341fcf138b727ecd09fe4f0c2defa0d Mon Sep 17 00:00:00 2001 From: Scott McCarty Date: Mon, 31 Aug 2026 07:17:39 -0400 Subject: [PATCH] fix: unpin onnxruntime, fix HUM-6564 at the source instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The <1.20 pin worked around the distroless segfault by holding the ONNX embedding runtime nine minor versions back. Fix the actual cause instead. onnxruntime vendors cpp_client_telemetry, which reads /etc/machine-id for a device ID. When the value is unusable it falls back to popen("blkid"), which returns NULL with no /bin/sh. The SDK does not check that, so the following pclose(NULL) segfaults on `import onnxruntime`. Upstream is onnxruntime#32173, fixed by #32226 but not yet in a release. Two independent guards: a populated /etc/machine-id (generated in the builder while root) and ORT_DISABLE_TELEMETRY=1. Verified on registry.access.redhat.com/hi/python:3.12, py 3.12.14, onnxruntime 1.29.0 — the ticket's exact environment: both guards -> imports OK telemetry on, id set -> imports OK telemetry off, no id -> imports OK both off -> SIGSEGV (139), reproduces the bug The file must be POPULATED; an empty "first boot" machine-id still segfaults. ORT_DISABLE_TELEMETRY also stops onnxruntime writing /tmp/mat-debug-1.log and /tmp/.ses, unwanted in this image regardless. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_013t1uJRVqhkikr52jXxxvck --- Containerfile | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/Containerfile b/Containerfile index 1dc92fa..4ca79e8 100644 --- a/Containerfile +++ b/Containerfile @@ -19,16 +19,30 @@ ARG SOURCE_VERSION=2026-08-30h # Install native libs needed by onnxruntime (libgomp) and numpy (libstdc++) USER 0 RUN dnf install -y --setopt=install_weak_deps=False libgomp libstdc++ tar gzip && dnf clean all + +# onnxruntime vendors cpp_client_telemetry, which reads /etc/machine-id for a +# device ID. When the value is unusable it falls back to popen("blkid"), and +# popen() returns NULL with no /bin/sh. The SDK does not check that, so the +# following pclose(NULL) segfaults the interpreter on `import onnxruntime`. +# That is HUM-6564 / onnxruntime#32173. +# +# The file must be POPULATED — measured against 1.29.0 with telemetry on: +# absent -> SIGSEGV(139) | empty -> SIGSEGV(139) | populated -> clean +# The empty "first boot" state is NOT enough. Needs root, so it lives here. +RUN tr -d - < /proc/sys/kernel/random/uuid > /etc/machine-id.seed + USER 65532 # Download and extract upstream source RUN curl -sL https://github.com/fatherlinux/mcp-memory-service/archive/refs/heads/main.tar.gz \ | tar xz --strip-components=1 -C /app -# Install CPU-only PyTorch then the package with ONNX embedding support -# Pin onnxruntime<1.20 — 1.29 segfaults in Hummingbird distroless (PyInit crash) +# Install CPU-only PyTorch then the package with ONNX embedding support. +# onnxruntime is no longer pinned: the <1.20 pin was a workaround for the +# distroless segfault, and it held the embedding runtime nine minor versions +# back. The populated /etc/machine-id above and ORT_DISABLE_TELEMETRY below +# each independently prevent that crash, verified against 1.29.0. RUN pip3.12 install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu && \ - pip3.12 install --no-cache-dir "onnxruntime<1.20" && \ pip3.12 install --no-cache-dir -e ".[sqlite]" RUN mkdir -p /app/sqlite_db /app/backups @@ -54,14 +68,24 @@ COPY --from=builder /usr/lib64/libstdc++.so* /usr/lib64/ COPY --from=builder /tmp/.local /tmp/.local COPY --from=builder /app /app +# Keeps onnxruntime's telemetry off its shell-based fallback — see stage 1 +COPY --from=builder /etc/machine-id.seed /etc/machine-id + ENV PYTHONUNBUFFERED=1 \ PYTHONPATH=/app/src \ PATH="/tmp/.local/bin:${PATH}" \ MCP_MEMORY_SQLITE_PATH=/app/sqlite_db/memory.db \ MCP_MEMORY_BACKUPS_PATH=/app/backups \ MCP_SSE_HOST=0.0.0.0 \ - MCP_SSE_PORT=8765 \ - HF_HUB_DISABLE_TELEMETRY=1 + MCP_SSE_PORT=8765 + +# Second, independent guard against the HUM-6564 crash, and appropriate on its +# own merits: left enabled, onnxruntime's init reads /etc/machine-id and +# /etc/os-release, writes /tmp/mat-debug-1.log and creates a session file at +# /tmp/.ses — not wanted in the image holding the whole memory corpus. +ENV HF_HUB_DISABLE_TELEMETRY=1 \ + ORT_DISABLE_TELEMETRY=1 \ + DO_NOT_TRACK=1 VOLUME ["/app/sqlite_db", "/app/backups"]