[Mlir-commits] [mlir] [mlir] Fix bug in PDLL Parser (PR #155243)

Youngsuk Kim llvmlistbot at llvm.org
Mon Aug 25 06:29:25 PDT 2025


https://github.com/JOE1994 created https://github.com/llvm/llvm-project/pull/155243

This reverts changes made to `mlir/lib/Tools/PDLL/Parser/Parser.cpp` in 095b41c6eedb3acc908dc63ee91ff77944c07d75 .

`raw_indented_ostream::printReindented()` reads from a string to which it also concurrently writes to, causing unintended behavior.

Credits to @jackalcooper for finding the issue.

>From d70b83d697f1431953df6a5c8a390ca1022810fa Mon Sep 17 00:00:00 2001
From: Youngsuk Kim <joseph942010 at gmail.com>
Date: Mon, 25 Aug 2025 06:18:41 -0700
Subject: [PATCH] [mlir] Fix bug in PDLL Parser

This reverts changes made to `mlir/lib/Tools/PDLL/Parser/Parser.cpp` in 095b41c6eedb3acc908dc63ee91ff77944c07d75 .

`raw_indented_ostream::printReindented()` reads from a string to which it also concurrently writes to,
causing unintended behavior.

Credits to @jackalcooper for finding the issue.
---
 mlir/lib/Tools/PDLL/Parser/Parser.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
index 51e702a1bb53a..c883baa7be2c5 100644
--- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp
+++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
@@ -147,8 +147,9 @@ class Parser {
     std::string docStr;
     {
       llvm::raw_string_ostream docOS(docStr);
+      std::string tmpDocStr = doc.str();
       raw_indented_ostream(docOS).printReindented(
-          StringRef(docStr).rtrim(" \t"));
+          StringRef(tmpDocStr).rtrim(" \t"));
     }
     return docStr;
   }



More information about the Mlir-commits mailing list