This is an automated email from the ASF dual-hosted git repository.
junrushao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git
The following commit(s) were added to refs/heads/main by this push:
new 79894c3 chore(test): Fix segfaults (#313)
79894c3 is described below
commit 79894c32315108e72e2ccc8f7d9e29118ee6919b
Author: Junru Shao <[email protected]>
AuthorDate: Thu Dec 4 16:27:27 2025 -0800
chore(test): Fix segfaults (#313)
---
tests/python/test_stl.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/python/test_stl.py b/tests/python/test_stl.py
index de7b982..43037a6 100644
--- a/tests/python/test_stl.py
+++ b/tests/python/test_stl.py
@@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+import gc
import pathlib
import pytest
@@ -52,6 +53,11 @@ def test_stl() -> None:
mod.test_function(lambda: 0)(100)
run_check(mod)
+ # Force garbage collection to ensure that all objects created from the
+ # module are destroyed before the module itself is unloaded. This
+ # prevents segfaults from calling destructors in an unloaded library.
+ gc.collect()
+ del mod
if __name__ == "__main__":