From 63f5240b64f17a98233727e206856ffc65835514 Mon Sep 17 00:00:00 2001 From: Paul Zhu Date: Mon, 28 Jul 2025 22:32:32 -0700 Subject: [PATCH] fix: hold gil before calling tree_cache().clear() --- python/src/transforms.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/src/transforms.cpp b/python/src/transforms.cpp index c47942b72..fcc283bba 100644 --- a/python/src/transforms.cpp +++ b/python/src/transforms.cpp @@ -1503,6 +1503,8 @@ void init_transforms(nb::module_& m) { // Register static Python object cleanup before the interpreter exits auto atexit = nb::module_::import_("atexit"); atexit.attr("register")(nb::cpp_function([]() { + nb::gil_scoped_acquire gil; + tree_cache().clear(); mx::detail::compile_clear_cache(); }));