#3536·mlc-llm

[Bug] macOS ARM64 mlc-llm-nightly-cpu pip wheel crashes entire Python process via silent exit(0) during import mlc_llm

Author: nitianabhigyanCreated Aug 21, 2026Updated Aug 21, 2026
Labelsbug

Bug

When installing the official mlc-llm-nightly-cpu and mlc-ai-nightly-cpu wheels via pip on an Apple Silicon Mac (M1), attempting to import mlc_llm results in an immediate, silent crash of the entire Python process.

The Python interpreter terminates with a 0 exit status code. No Python traceback, stderr log, or macOS Crash Report is generated. We traced the failure down to the C-level: the bundled libtvm_runtime.dylib calls exit(0) internally during its static C++ initialization phase when loaded via dlopen.

To Reproduce

Steps to reproduce the behavior:

  1. Create a clean Python environment on a macOS ARM64 machine.
  2. Install the nightly CPU packages:
    bash
    pip install --pre -U -f https://mlc.ai/wheels mlc-llm-nightly-cpu mlc-ai-nightly-cpu
  3. Attempt to import the module in Python:
    python
    import mlc_llm
    print("SUCCESS")
    Output: The script terminates immediately before printing "SUCCESS". The shell exit code is 0.

To isolate the issue from Python, we wrote a raw C program to manually dlopen the bundled library:

c
#include <dlfcn.h>
#include <stdio.h>

int main() {
    setvbuf(stdout, NULL, _IONBF, 0);
    printf("Loading TVM Runtime...\n");
    
    // Adjust path to your site-packages
    void* handle = dlopen("lib/python3.11/site-packages/tvm/lib/libtvm_runtime.dylib", RTLD_LAZY | RTLD_GLOBAL);
    
    printf("This line is NEVER reached!\n");
    return 0;
}

Result of C-Test:

bash
$ clang test_dlopen.c -o test_dlopen
$ ./test_dlopen
Loading TVM Runtime...
$ echo $?
0

The dlopen call never returns and silently forces the process to exit with code 0.

Expected behavior

The module should import successfully. If there is a hardware mismatch or missing backend initialization (e.g., Metal support missing), the library should throw an exception, return a non-zero error code, or abort() so the error can be caught, rather than silently calling exit(0).

Environment

  • Platform (e.g. WebGPU/Vulkan/IOS/Android/CUDA): Metal
  • Operating system (e.g. Ubuntu/Windows/MacOS/...): MacOS
  • Device (e.g. iPhone 12 Pro, PC+RTX 3090, ...): Mac mini (M1, Apple Silicon)
  • How you installed MLC-LLM (conda, source): pip (mlc-llm-nightly-cpu 0.26.dev6)
  • How you installed TVM (pip, source): pip (mlc-ai-nightly-cpu 0.26.dev246)
  • Python version (e.g. 3.10): 3.11.15
  • GPU driver version (if applicable): N/A
  • CUDA/cuDNN version (if applicable): N/A
  • TVM Hash Tag (python -c "import tvm; print('\n'.join(f'{k}: {v}' for k, v in tvm.support.libinfo().items()))", applicable if you compile models): N/A - Cannot run import tvm without the process silently exiting.
  • Any other relevant information: This affects the pre-compiled macosx_arm64 wheels distributed on https://mlc.ai/wheels.

Additional context

It is highly likely that one of the static global C++ constructors (__attribute__((constructor))) inside the pre-compiled libtvm_runtime.dylib wheel is encountering a fatal state and executing an exit(0) command. Auditing the global static initializers in the TVM macOS build pipeline to replace exit(0) calls with proper aborts or exceptions would expose the true underlying initialization error.