Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio sd.cpp install: treat ELF symbol-version mismatches as loader refusals (#16150)
Daniel Hand27af99ea2b4
diff --git a/studio/backend/tests/test_sd_cpp_install_verify.py b/studio/backend/tests/test_sd_cpp_install_verify.pyindex 49a161e7a02..fea8f517a6b 100644--- a/studio/backend/tests/test_sd_cpp_install_verify.py+++ b/studio/backend/tests/test_sd_cpp_install_verify.py@@ -12,6 +12,7 @@ import sysimport typesimport zipfilefrom pathlib import Path+from typing import Optionalimport pytest@@ -123,6 +124,65 @@ def test_the_loader_refusal_is_read_from_the_exit_status_and_output():assert sdmod.loader_refusal(None) is None+def test_a_glibc_symbol_version_failure_is_a_loader_refusal():+ assert sdmod.loader_refusal(+ 1,+ "./sd-cli: /opt/sd/libstable-diffusion.so: version `LIBDEMO_2' not found "+ "(required by ./sd-cli)",+ )+ assert sdmod.loader_refusal(+ 1,+ "./sd-cli: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by ./sd-cli)",+ )+ assert sdmod.loader_refusal(1, "error: model file not found") is None+++def _build_version_mismatch(tmp: Path) -> Optional[Path]:+ import shutil+ import subprocess++ cc = shutil.which("cc") or shutil.which("gcc")+ if _WIN or sys.platform == "darwin" or not cc:+ return None+ (tmp / "v1.map").write_text("LIBDEMO_1 { global: demo; local: *; };\n")+ (tmp / "v2.map").write_text("LIBDEMO_2 { global: demo; local: *; };\n")+ (tmp / "lib.c").write_text("int demo(void) { return 0; }\n")+ (tmp / "main.c").write_text("int demo(void);\nint main(void) { return demo(); }\n")+ build = tmp / "build"+ build.mkdir()+ try:+ for ver, out in (("v2.map", build / "libdemo.so"), ("v1.map", tmp / "libdemo.so")):+ subprocess.run(+ [+ cc,+ "-shared",+ "-fPIC",+ f"-Wl,--version-script={tmp / ver}",+ "-o",+ str(out),+ str(tmp / "lib.c"),+ ],+ check = True,+ capture_output = True,+ )+ exe = tmp / _CLI+ subprocess.run(+ [cc, "-o", str(exe), str(tmp / "main.c"), f"-L{build}", "-ldemo"],+ check = True,+ capture_output = True,+ )+ except (OSError, subprocess.CalledProcessError):+ return None+ return exe+++def test_probe_refuses_a_real_elf_whose_library_lacks_the_needed_version(tmp_path):+ exe = _build_version_mismatch(tmp_path)+ if exe is None:+ pytest.skip("needs a Linux C toolchain")+ assert sdmod.probe_binary_starts(exe)++def test_probe_reports_a_refused_binary_and_passes_a_starting_one(tmp_path):bad = tmp_path / "bad" / _CLIgood = tmp_path / "good" / _CLI@@ -153,6 +213,24 @@ def test_a_bundle_that_cannot_start_never_replaces_the_working_one(tmp_path, monassert not list(root.parent.glob(".sd-cpp-verify-*"))[email protected](_WIN, reason = "glibc loader message")+def test_a_symbol_version_refusal_never_replaces_the_working_one(tmp_path, monkeypatch):+ root = _managed_root(tmp_path, monkeypatch)+ old_server = _working_vulkan_install(root)+ before = old_server.read_bytes()+ refused = (+ b"#!/bin/sh\necho \"$0: /opt/libstable-diffusion.so: version \\`LIBDEMO_2' not found "+ b'(required by $0)" >&2\nexit 1\n'+ )+ _stub_release(monkeypatch, {"rocm": _bundle(refused)})++ with pytest.raises(sdmod.UnrunnableBuildError):+ sdmod.install(install_dir = root, accelerator = "rocm")++ assert old_server.is_file() and old_server.read_bytes() == before+ assert sdmod.read_install_record(root).get("accelerator") == "vulkan"++def test_the_refusal_names_what_was_asked_for(tmp_path, monkeypatch):root = _managed_root(tmp_path, monkeypatch)_stub_release(monkeypatch, {"rocm": _bundle(_refused_binary())})diff --git a/studio/install_sd_cpp_prebuilt.py b/studio/install_sd_cpp_prebuilt.pyindex 9dfbf906a23..65146b1c736 100644--- a/studio/install_sd_cpp_prebuilt.py+++ b/studio/install_sd_cpp_prebuilt.py@@ -702,7 +702,12 @@ _WINDOWS_LOADER_FAILURES = {0xC0000139: "a DLL it imports is the wrong build", # STATUS_ENTRYPOINT_NOT_FOUND0xC0000142: "a DLL it imports failed to initialise", # STATUS_DLL_INIT_FAILED}-_POSIX_LOADER_MARKERS = ("error while loading shared libraries", "Library not loaded")+# glibc elf/dl-version.c exits before main without the shared-libraries error prefix.+_POSIX_LOADER_MARKERS = (+ "error while loading shared libraries",+ "Library not loaded",+ "' not found (required by ",+)def verify_install_enabled() -> bool: