Skip to content

Fix Linux multiarch dependency detection and OVMS libxml2 crash - #558

Open
beranradek wants to merge 2 commits into
intel:mainfrom
beranradek:fix/linux-multiarch-dpkg-query-check
Open

Fix Linux multiarch dependency detection and OVMS libxml2 crash#558
beranradek wants to merge 2 commits into
intel:mainfrom
beranradek:fix/linux-multiarch-dpkg-query-check

Conversation

@beranradek

@beranradek beranradek commented Aug 8, 2026

Copy link
Copy Markdown

Summary

Two related bugs affecting Linux systems with a foreign architecture enabled (e.g. i386 packages pulled in by Wine or Steam), both caused by code that reads multiarch dpkg/ldconfig output without being architecture-aware.

1. isAptPackageInstalled() wrongly reports installed packages as missing

WebUI/electron/subprocesses/linuxPackageInstaller.ts runs dpkg-query -W -f='${db:Status-Status}' <pkg> without an architecture qualifier and compares the output to the exact string installed. On a multiarch system, dpkg-query matches one record per installed architecture and concatenates the status field with no separator, e.g. installedinstalled for a package installed for both amd64 and i386. That breaks the exact-match check even though the package genuinely is installed, so OpenVINO (and ComfyUI) Linux setup wrongly reports required packages as still missing after the installer step runs, and setup fails with Dependencies still missing after installer: libgomp1, libnuma1, ocl-icd-libopencl1.

Reproduced on a stock Ubuntu install with libwine:i386/libx265-215:i386/libsoxr0:i386 present, which pull in i386 copies of libgomp1, libnuma1, and ocl-icd-libopencl1 alongside the amd64 ones already required by OpenVINO.

Fix: accept any repetition of installed (covers 1+ architectures reporting the same status) while still rejecting unrelated statuses that contain the substring, like not-installed:

return /^(installed)+$/.test(stdout.trim())

2. OVMS crashes with wrong ELF class: ELFCLASS32 loading libxml2

ensureOvmsMissingLibSymlinks() resolves a missing OVMS shared library (e.g. libxml2.so.2) to a compatible system library via a soname -> path map built from ldconfig -p. On the same kind of multiarch system, ldconfig -p lists one entry per architecture under the identical soname key with no architecture-aware precedence:

libxml2.so.16 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libxml2.so.16
libxml2.so.16 (libc6)        => /usr/lib/i386-linux-gnu/libxml2.so.16

The map ends up keyed to whichever line happens to come last. When that's the i386 line, the compat symlink points OVMS (a 64-bit process) at a 32-bit library, and OVMS crashes on startup with error while loading shared libraries: libxml2.so.2: wrong ELF class: ELFCLASS32. This surfaces in the UI as "Failed to start transcription server" when enabling Speech to Text, and would affect any other OVMS feature needing the same kind of fallback library.

Fix: extract the ldconfig -p parsing into parseLdconfigOutput() and make it architecture-aware: an x86-64-tagged entry always wins over a foreign-arch entry for the same soname, regardless of line order. AI Playground's Linux build targets x86-64 only, so this is safe and matches the existing hardcoded x86_64-linux-gnu paths used elsewhere in this file's Linux support code.

Test plan

  • Added linuxPackageInstaller.test.ts covering single-arch and multiarch dpkg-query output.
  • Added openVINOBackendService.test.ts covering parseLdconfigOutput() with real multiarch ldconfig -p output reproduced from an affected system (x86-64 entry first, foreign-arch entry first, foreign-arch-only fallback, unparsable lines).
  • Reproduced the libxml2.so.2 ELFCLASS32 crash on a live installation (Ubuntu with i386 foreign architecture enabled) and confirmed the fix resolves it: ldd on the OVMS binary now resolves libxml2.so.2 to the x86-64 library instead of the i386 one.
  • Full electron test suite (npx vitest run electron/test/subprocesses/), tsc --noEmit, and eslint pass with no regressions.
  • Manually verified against a real multiarch Ubuntu install where OpenVINO setup previously failed; after patching, dependency detection and the OVMS compat-symlink logic both behave correctly.

🤖 Generated with Claude Code

Radek Beran and others added 2 commits August 8, 2026 17:00
isAptPackageInstalled() queried dpkg-query without an architecture
qualifier and compared the output to the exact string "installed".
On any system with a foreign architecture enabled (e.g. i386 packages
pulled in by Wine or Steam), dpkg-query matches one record per
installed architecture and concatenates the status field with no
separator, e.g. "installedinstalled" for a package installed for both
amd64 and i386. That fails the exact-match check even though the
package genuinely is installed, so OpenVINO/ComfyUI Linux setup wrongly
reports required packages (libgomp1, libnuma1, ocl-icd-libopencl1, ...)
as still missing after the installer runs, and setup fails with
"Dependencies still missing after installer".

Accept any repetition of "installed" while still rejecting unrelated
statuses that contain it as a substring (e.g. "not-installed").
ensureOvmsMissingLibSymlinks() resolves a missing OVMS shared library (e.g.
libxml2.so.2) to a compatible system library by building a soname -> path map
from `ldconfig -p` output. On a system with a foreign architecture enabled
(e.g. i386 pulled in by Wine/Steam), ldconfig -p lists one entry per installed
architecture under the same soname with no architecture-aware precedence, so
the map ends up keyed to whichever line happens to come last:

  libxml2.so.16 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libxml2.so.16
  libxml2.so.16 (libc6)        => /usr/lib/i386-linux-gnu/libxml2.so.16

When the i386 line wins, the compat symlink points OVMS (a 64-bit process) at
a 32-bit library, and OVMS crashes on startup with "error while loading shared
libraries: libxml2.so.2: wrong ELF class: ELFCLASS32", which surfaces in the
UI as "Failed to start transcription server" (and would affect any other OVMS
feature needing a fallback library).

Extract the parsing into parseLdconfigOutput() and make it architecture-aware:
an x86-64-tagged entry always wins over a foreign-arch one for the same
soname, regardless of line order. AI Playground's Linux build targets x86-64
only, so this is safe and matches the existing hardcoded x86_64-linux-gnu
paths used elsewhere in this file's Linux support code.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@beranradek beranradek changed the title Fix Linux dependency check on multiarch systems (i386 + amd64) Fix Linux multiarch dependency detection and OVMS libxml2 crash Aug 9, 2026
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