Skip to content

sd.cpp prebuilt installer flattens archive symlinks, breaking sd-cli on Linux (lib*.so: file too short) #9268

Closed

Description

@FrancescoBrunoDev

Summary

After studio/install_sd_cpp_prebuilt.py extracts the sd.cpp release zip, every shared-library symlink in build/bin/ becomes a tiny regular file containing the link-target text. sd-cli/sd-server then can't start, so MiniMax-H3 reports video.load_failed: stable-diffusion.cpp could not be installed or started for MiniMax-H3.

ldd ~/.unsloth/stable-diffusion.cpp/build/bin/sd-cli
  error while loading shared libraries: .../libwebpmux.so.3: file too short

Root cause

_safe_extractall() calls zipfile.extractall(). CPython's zipfile does not restore symlinks — it writes each symlink member's data (the target path) as a regular file. Upstream release zips ship libggml*.so, libggml.so*, libwebp*.so, libwebpmux*.so, libsharpyuv*.so as symlinks, so after extraction e.g. libwebpmux.so.3 is a 19-byte file containing libwebpmux.so.3.1.2.

Fix suggestion

Recreate symlink members after extraction, with the same containment guard used for member paths:

for member in zf.infolist():
    ...
    if stat.S_ISLNK(member.external_attr >> 16):
        links.append((dest, zf.read(member).decode("utf-8", "surrogateescape"), member.filename))
zf.extractall(target)
for dest, link_target, filename in links:
    resolved = (dest.parent / link_target).resolve()
    if resolved != base and base not in resolved.parents:
        raise RuntimeError(f"unsafe symlink in archive: {filename!r} -> {link_target!r}")
    if dest.is_symlink() or dest.exists():
        dest.unlink()
    dest.symlink_to(link_target)

Environment

  • OS: Omarchy 4.0.0 (Arch Linux-based), kernel 7.1.8-arch1-3
  • CPU: AMD Ryzen AI Max+ 395 (32 threads)
  • GPU: AMD Radeon 8060S (gfx1151), ROCm
  • RAM: 128 GB unified
  • Python: 3.13.15
  • Unsloth package: unsloth 2026.8.18
  • Triggering asset: leejet/stable-diffusion.cpp release master-813-bfbef5b, sd-master-bfbef5b-bin-Linux-Ubuntu-24.04-x86_64-rocm-7.14.0.zip

Workaround (until fixed)

Recreate the links after install: each flattened file's content is its link target.

Activity

  1. added a commit that references this issue on Aug 24, 2026
    7ce506b
  2. added a commit that references this issue on Aug 24, 2026
    2921990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions