Issue 129216
Summary [mlir][td] check-use-after-free.mlir failing (AppleSillcon + shared libs)
Labels mlir
Assignees banach-space
Reporter banach-space
    Hi,

[check-use-after-free.mlir](https://github.com/llvm/llvm-project/blob/main/mlir/test/Dialect/Transform/check-use-after-free.mlir) fails for for me  on **AppleSilicon** (checked on M3 and M4) with:
* -DBUILD_SHARED_LIBS=**On**

(static libs build is fine). 

I've tracked it down to the TD logic incorrectly assuming that at runtime there will be only one instance of [DerivedResource](https://github.com/llvm/llvm-project/blob/78c96aa24f0406e630674d82eef073ea3d4c8141/mlir/include/mlir/Interfaces/SideEffectInterfaces.h#L90-L93). That assumption is effectively made here: https://github.com/llvm/llvm-project/blob/78c96aa24f0406e630674d82eef073ea3d4c8141/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td#L132

I actually end up with **two** instances of that class at runtime, both are instantiations of:
```cpp
mlir::SideEffects::Resource::Base<mlir::transform::TransformMappingResource, mlir::SideEffects::Resource>:
```

* one instance "lives" in `libMLIRTransformDialectInterfaces.dylib`, 
* another instances "lives" in `libMLIRTransformDialectTransforms.dylib`.

**QUESITON:**

Should I update [getEffectsOnResource](https://github.com/llvm/llvm-project/blob/78c96aa24f0406e630674d82eef073ea3d4c8141/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td#L132) to compare `ResourceID` instead?
```cpp
return it.getResource()->getResourceID() != resource->getResourceID();
```

https://github.com/llvm/llvm-project/blob/78c96aa24f0406e630674d82eef073ea3d4c8141/mlir/include/mlir/Interfaces/SideEffectInterfaces.h#L108

Alternatively, we could explore ways to ensure that there is only one instance across all shared objects, but I’m not sure how best to achieve that.

@ftynse, could you take a look when you get a chance? "git log" wasn’t very helpful here (this logic depends on quite a few components), and you’re my go-to TD expert. 🙂

—Andrzej
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to