Skip to content

Segfault on Launch After Successful Build on macOS arm64 (M1 iMac) #1173

@Cee-JayM13

Description

@Cee-JayM13
  1. Environment:
  • Hardware: M1 iMac (arm64)
  • OS: macOS Tahoe 26.1
  • Rust: rustc 1.91.1 (ed61e7d7e 2025-11-07)
  • Cargo: cargo 1.91.1 (ea2d97820 2025-10-10)
  • Python: Homebrew Python 3.14.2 [main] // pyenv Python 3.12.12 (framework build) [tested, result was unsuccessful]
  • VapourSynth: R73 (installed via Homebrew → "build install --build-from-source vapoursynth" [Note: The default "brew install vapoursynth" Homebrew VS R73 installation has also been tested & similarly encounters the same following issue(s)]
  • Homebrew: Homebrew 5.0.4-68-g70badad // Homebrew/homebrew-core (git revision a9f969c41ca; last commit 2025-12-07)
  • av1an: Cloned from main branch (v0.5.0 or latest commit)
  • Other deps: ffmpeg (Homebrew), innumerable Homebrew-installed libraries for video processing

All components are arm64-native (confirmed via file on binaries and dylibs).

  1. Reproduction Steps:
brew install vapoursynth python@3.14 ffmpeg
git clone https://github.com/rust-av/Av1an.git
cd Av1an

Required for linking on macOS (otherwise undefined vsscript* symbols)_

mkdir -p ~/.cargo && cat > ~/.cargo/config.toml <<EOF
[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"]
EOF

cargo build --release
./target/release/av1an --version → immediate segfault (zsh: segmentation fault)

  1. Issue Description:

I've been attempting to build and run av1an on my M1 iMac for roughly the last ~two weeks; initially failures were primarily centered on compilation errors (ex. linking issues, "ld: symbol(s) not found for architecture arm64" errors & vsscript issues). After extensive troubleshooting (including mostly failed DIY patches, shim.c files, attempts at creating various build.sh scripts with patches contained within, etc. I ultimately ended up creating a custom ~/.cargo/config.toml file [to which I attribute my minimally made progress towards - in furtherance of obtaining a fully functional, feature-complete arm64 M1 iMac compatible av1an executable]), I can now successfully compile the executable without errors. However, it segfaults immediately on launch, even for basic commands like path/to/av1an --version. No output is produced since the process crashes before loading anything meaningful.

  1. Past attempts (pre-successful build):
  • Frequent (99%+) failure rate during cargo build, often resulting from arm64-specific linking errors with vapoursynth-sys or pyo3.
  • The rare successeful av1an executable builds required manual patches/shims, but the resulting binary was unusable (i.e. wouldn't execute at all).

Current state (post-successful build):

  • Build completes in ~2-4 minutes depending on clean/rebuild/background programs running.
  • Binary is created at target/release/av1an (arm64, confirmed).
  • Segfaults on any form of invocation: ex. zsh: segmentation fault /path/to/av1an --version
  • Standalone Python tests (ex. importing vapoursynth) work perfectly.
  • Disabling VapourSynth plugins (mv /opt/homebrew/lib/vapoursynth /opt/homebrew/lib/vapoursynth.disabled) does not prevent the crash, suggesting it's not a plugin issue.
  • LLDB backtraces show the crash in libvapoursynth-script.0.dylib during vapoursynth::script::Environment::create() (environment.cpp:49), with EXC_BAD_ACCESS (null pointer dereference). Example backtrace:
    * frame #0: 0x0000000104e9f0a4 libvapoursynth-script.0.dylib`vapoursynth::script::Environment::create(this=0x000000016b4e1d00) at environment.cpp:49:18
      frame #1: 0x0000000104e9ef7c libvapoursynth-script.0.dylib`vapoursynth::script::Environment::Environment(this=0x000000016b4e1d00) at environment.cpp:25:5
      [truncated; full backtraces show Python C API calls leading to this]
    
  • otool -L on the av1an binary shows correct links, ex.:
    /Users/Cee-JayM13/Av1an/target/release/av1an:
      /opt/homebrew/opt/vapoursynth/lib/libvapoursynth.dylib (compatibility version 0.0.0, current version 0.0.0)
      /opt/homebrew/opt/vapoursynth/lib/libvapoursynth-script.0.dylib (compatibility version 0.0.0, current version 0.0.0)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1356.0.0)
    
  • otool -L on vapoursynth.abi3.so confirms links to Homebrew libs.
  1. Troubleshooting:
  • Performed av1an build tests with venvs and pyenv framework Python 3.12.x to align build/runtime interpreters - no success.
  • Set PYTHON_SYS_EXECUTABLE during build to match runtime Python - no success.
  • Verified architectures (all arm64) and paths (ex. site-packages, dylibs in /opt/homebrew/lib) - to no avail regardless.
  • Tested DYLD_LIBRARY_PATH and DYLD_FRAMEWORK_PATH workarounds (ex. export DYLD_LIBRARY_PATH="/opt/homebrew/opt/vapoursynth/lib"), but segfault annoyingly persists.
  • Checked for ABI mismatches, outdated wheels, or missing dylibs - none apparent.
  • Extensive debugging with LLDB, otool, and file commands; standalone VapourSynth works.
  1. Suspected Points of Failure (Summarized):

Through extensive troubleshooting including repeated LLDB sessions, detailed crash backtraces, runtime analysis, reviewing of terminal build logs supplemented by AI-assisted interpretation/result summarization & targeted research on Stack Overflow & related Rust/macOS forums, the following represent what I believe are the most likely root causes of the immediate segfault on launch:

  • 1.) Outdated PyO3 in Dependency Tree: The av1an dependency, vapoursynth-rs (v0.4.1), relies on an older version of PyO3 (likely ~0.17.x). PyO3 versions prior to 0.18+ are known to contain bugs that cause segfaults during Python embedding on macOS arm64, typically during interpreter initialization or module imports.

  • 2.) VapourSynth Script Library Crash: The crash consistently appears to happen deep inside libvapoursynth-script during the Environment::create() call. This strongly suggests a failure in the C++/Python bridge's initialization, possibly due to arm64-specific symbol or ABI mismatches that are not caught at build time.

  • 3.) macOS Framework Strictness: The arm64 ecosystem on macOS is notoriously strict regarding framework builds (like those from pyenv or Homebrew). The dynamic linker (Dyld) seems to be failing to correctly resolve the embedded Python paths within the av1an binary, leading to null pointers when VapourSynth tries to create its scripting environment.

Unfortunately, I am nowhere near experienced enough to dive deeper into the code than I already have. I've been DIY troubleshooting this for over a week, and while I finally won the battle to get it built, getting it to actually link and execute properly has proven to be outside my capabilities. From the poking & prodding around I've done and from what I've learned online, the information points toward a compatibility bug in the embedding stack rather than simple user error, likely due to the strictness of the macOS arm64 environment. I suspect, perhaps, that the project just hasn't had adequate testing on this specific platform recently.

I’d appreciate any guidance (if currently possible) on meaningful ways to get av1an up and running with full VS compatibility and support on my system architecture/OS. At the very least, I wanted to get this problem out into the public conciousness and hopefully heard by someone with more knowledge, know-how & most crucially -> the means to actively create a permanent fix(es)/solution(s) to this problem. Thanks for reading!

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