[Mlir-commits] [mlir] [MLIR:Python] Fix race on PyOperations. (PR #139721)

Maksim Levental llvmlistbot at llvm.org
Tue May 13 11:55:11 PDT 2025


================
@@ -1638,12 +1728,17 @@ nb::object PyOperation::createOpView() {
   return nb::cast(PyOpView(getRef().getObject()));
 }
 
-void PyOperation::erase() {
+void PyOperation::eraseLocked() {
   checkValid();
   getContext()->clearOperationAndInside(*this);
   mlirOperationDestroy(operation);
 }
 
+void PyOperation::erase() {
+  nb::ft_lock_guard lock(getContext()->liveOperationsMutex);
+  eraseLocked();
+}
+
----------------
makslevental wrote:

is this called anywhere? don't think so

https://github.com/llvm/llvm-project/pull/139721


More information about the Mlir-commits mailing list