[all-commits] [llvm/llvm-project] aa84e6: [mlir] Fix undefined behavior in Linalg utils getV...

ftynse via All-commits all-commits at lists.llvm.org
Tue Jul 21 00:58:04 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: aa84e6e579bedffda43f8ebffa553cf277947e96
      https://github.com/llvm/llvm-project/commit/aa84e6e579bedffda43f8ebffa553cf277947e96
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2020-07-21 (Tue, 21 Jul 2020)

  Changed paths:
    M mlir/include/mlir/Dialect/Linalg/Utils/Utils.h

  Log Message:
  -----------
  [mlir] Fix undefined behavior in Linalg utils getViewSizes

The utility function getViewSizes in Linalg has been recently updated to
support a different form of Linalg operations. In doing so, the code looking
like `smallvector.push_back(smallvector[i])` was introduced. Unlike std
vectors, this can lead to undefined behavior if the vector must grow upon
insertion: `smallvector[i]` returns a reference to the element, `push_back`
takes a const reference to the element, and then grows the vector storage
before accessing the referenced value. After the resize, the reference may
become dangling, which leads to undefined behavior detected by ASAN as
use-after-free. Work around the issue by forcing the value to be copied by
putting it into a temporary variable.




More information about the All-commits mailing list