Repository navigation
Conversation
Contributor
Author
|
Hi @tlopex @MasterJH5574, could you help review this when you have time? It fixes the flaky |
LiRunGuo
force-pushed
the
fix/relax-py-func-registry
branch
from
October 12, 2026 20:53
bf215fb to
301df76
Compare
Contributor
Author
|
Since #20417 already fixed the flaky test by scoping registry entries to their module, I rebased and reduced this PR to the remaining exit crash (process segfaults if a Python function is still registered at exit). @tlopex @MasterJH5574 could you take a look? Thanks! |
The Python function registry used by `R.call_py_func` was a static
std::unordered_map. Its destructor runs during static destruction, after
the Python interpreter has been finalized, and releases the Python
callables it still holds. Any process that exits with a function still
registered therefore crashes:
import tvm
tvm.get_global_func("vm.builtin.register_py_func")("f", lambda x: x)
# exits with SIGSEGV
Make the registry a heap-allocated singleton that is never destroyed, so
nothing is released after finalization, and add a test that a process
exiting with a function still registered returns 0.
LiRunGuo
force-pushed
the
fix/relax-py-func-registry
branch
from
November 3, 2026 16:41
301df76 to
cf4fb50
Compare
Contributor
Author
|
Rebased onto current |
This branch has not been deployed
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.
The Python function registry used by
R.call_py_funcis a staticstd::unordered_map. Its destructor runs during static destruction, after the Python interpreter has been finalized, and releases the Python callables it still holds. Any process that exits with a function still registered therefore crashes:This makes the registry a heap-allocated singleton that is never destroyed, so nothing is released after finalization. The new test runs the snippet above in a subprocess and checks that it exits with code 0; it fails on current main and passes with this change.
tests/python/relax/test_relax_operators.pyand the relax test suite otherwise pass.Note: the first version of this PR also fixed the flaky
test_op_call_py_funcfailure caused byBasePyModule.__del__clearing the whole registry. #20417 has since fixed that with per-module ownership, so I rebased onto main and reduced this PR to the exit crash, which #20417 does not address.