[FIX] Load ORC JIT addon through TVM-FFI - #809
Merged
Merged
Conversation
tqchen
approved these changes
Sep 21, 2026
cyx-6
force-pushed
the
codex/orcjit-tvm-load-module
branch
from
September 21, 2026 16:13
684d1c7 to
c987791
Compare
cyx-6
force-pushed
the
codex/orcjit-tvm-load-module
branch
from
September 22, 2026 09:27
f7a5a63 to
b37ff54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
#807 localized the ORCJIT addon and its linked runtimes, but retained a second raw
ctypes.CDLL(..., RTLD_NODELETE)handle to keep the addon mapped through process shutdown. The addon should use the standardtvm_ffi.load_modulepath exclusively.Simply deleting the raw handle exposed a SIGSEGV during process exit when a JIT module was pinned with
keep_module_alive=True. TVM-FFI'sModuleGlobalsdescribes its entries as modules that should not be unloaded, but the registry itself was a destructible function-local static. Static teardown could therefore unload a DSO while the process-global function table and other dependents still held callbacks whose code belonged to it.What changed
tvm_ffi.load_module(..., keep_module_alive=True)ctypes.CDLL,RTLD_NODELETE, and Windows DLL-directory handlingkeep_module_alivedocumentation to state that pinned modules live for the duration of the processValidation
ModuleGlobalslifetime fix, the new shutdown reproducer exited with SIGSEGV (returncode == -11)manylinux_2_28ARM64 container with LLVM 22.1.0nm -D --defined-only: exactlyTVMFFIOrcJITInitialize