[Mlir-commits] [mlir] [MLIR:Python] Fix race on PyOperations. (PR #139721)
Maksim Levental
llvmlistbot at llvm.org
Tue May 13 11:53:25 PDT 2025
================
@@ -770,7 +846,7 @@ void PyMlirContext::clearOperationAndInside(PyOperationBase &op) {
MlirOperationWalkCallback invalidatingCallback = [](MlirOperation op,
void *userData) {
PyMlirContextRef &contextRef = *static_cast<PyMlirContextRef *>(userData);
- contextRef->clearOperation(op);
+ contextRef->clearOperationLocked(op);
----------------
makslevental wrote:
oh it's because the call chain is `erase` (which takes the lock) -> `eraseLocked` -> `clearOperationAndInside` -> `clearOperationLocked`.
yea these are sharp edges in my opinion - there being no assertions that a lock is actually held. at minimum we should propagate the `Locked` convention throughout the call chain, i.e. this method should be renamed `clearOperationAndInsideLocked` (this is of course unfortunate/tedious but i think there's now out of "coloring" the methods)
https://github.com/llvm/llvm-project/pull/139721
More information about the Mlir-commits
mailing list