[Mlir-commits] [mlir] [mlir] Fix use-after-free bugs in {RankedTensorType|VectorType}::Builder (PR #68969)

Benjamin Maxwell llvmlistbot at llvm.org
Tue Oct 17 00:04:20 PDT 2023


================
@@ -277,7 +277,7 @@ class RankedTensorType::Builder {
     if (storage.empty())
       storage.append(shape.begin(), shape.end());
     storage.erase(storage.begin() + pos);
-    shape = {storage.data(), storage.size()};
+    shape = {};
----------------
MacDue wrote:

I don't know what you mean by dropping information on the floor. Nothing is lost when the shape is made empty as it's been copied to the storage. 

Anyway, I think the storage filed is a premature optimization. Most shapes will fit in the inline storage of the SmallVector and the main use of the builder (altering dims) requires the storage anyway. So I'll just make shape a SmallVector and remove the copy-on-write stuff.


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


More information about the Mlir-commits mailing list