[PATCH] D78850: Memory corruption issure for DenseStringElementsAttr

Rob Suderman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 24 20:02:20 PDT 2020


rsuderman created this revision.
rsuderman added a reviewer: rriddle.
Herald added subscribers: llvm-commits, Kayjukh, frgossen, grosul1, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, mehdi_amini.
Herald added 1 blocking reviewer(s): rriddle.
Herald added a project: LLVM.
rriddle accepted this revision.
This revision is now accepted and ready to land.

There was a memory corruption issue where the lifespan of the ArrayRef<StringRef> would fail. Directly passing the data will avoid the issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78850

Files:
  mlir/lib/IR/AttributeDetail.h


Index: mlir/lib/IR/AttributeDetail.h
===================================================================
--- mlir/lib/IR/AttributeDetail.h
+++ mlir/lib/IR/AttributeDetail.h
@@ -610,8 +610,8 @@
       if (!firstElt.equals(data[i]))
         return KeyTy(ty, data, llvm::hash_combine(hashVal, data.drop_front(i)));
 
-    // Otherwise, this is a splat so just return the hash of the first element.
-    return KeyTy(ty, {firstElt}, hashVal, /*isSplat=*/true);
+    // Otherwise, this is a splat.
+    return KeyTy(ty, data, hashVal, /*isSplat=*/true);
   }
 
   /// Hash the key for the storage.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78850.260055.patch
Type: text/x-patch
Size: 594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200425/1c351138/attachment.bin>


More information about the llvm-commits mailing list