[Bug] macOS ARM64 mlc-llm-nightly-cpu pip wheel crashes entire Python process via silent exit(0) during import mlc_llm
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:
- Create a clean Python environment on a macOS ARM64 machine.
- Install the nightly CPU packages:
pip install --pre -U -f https://mlc.ai/wheels mlc-llm-nightly-cpu mlc-ai-nightly-cpu - Attempt to import the module in Python:Output: The script terminates immediately before printing "SUCCESS". The shell exit code is
import mlc_llm print("SUCCESS")0.
To isolate the issue from Python, we wrote a raw C program to manually dlopen the bundled library:
#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:
$ clang test_dlopen.c -o test_dlopen
$ ./test_dlopen
Loading TVM Runtime...
$ echo $?
0The 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-cpu0.26.dev6) - How you installed TVM (
pip, source):pip(mlc-ai-nightly-cpu0.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 runimport tvmwithout the process silently exiting. - Any other relevant information: This affects the pre-compiled
macosx_arm64wheels distributed onhttps://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.
Source: mlc-ai/mlc-llm