Module: Mesa
Branch: staging/23.3
Commit: 530e0c153992599e137844c2285d0de7cc35187c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=530e0c153992599e137844c2285d0de7cc35187c

Author: Gert Wollny <gert.wol...@collabora.com>
Date:   Thu Nov 30 13:43:11 2023 +0100

r600/sfn: Don't try to re-use iterators when the set is made empty

It seems with libc++ the iterators are invalidated when the set
is emptied during iterating over it.

Fixes: 05fab97 (r600/sfn: Don't try to re-use the iterator when uses is updated)

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7931

Signed-off-by: Gert Wollny <gert.wol...@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26420>
(cherry picked from commit c13de0509c43f9b9764dc939aa64fe70c6a80870)

---

 .pick_status.json                              | 2 +-
 src/gallium/drivers/r600/sfn/sfn_optimizer.cpp | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 12fcfdf1d33..6952b34293f 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -494,7 +494,7 @@
         "description": "r600/sfn: Don't try to re-use iterators when the set 
is made empty",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "05fab97b2ce8ebd8420ded175101a0fa5110172c",
         "notes": null
diff --git a/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp 
b/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp
index c4d0a9fa727..5038b94ab6e 100644
--- a/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp
@@ -375,7 +375,11 @@ CopyPropFwdVisitor::visit(AluInstr *instr)
 
    auto mov_block_id = instr->block_id();
 
-   while(ii != ie) {
+   /** libc++ seems to invalidate the end iterator too if a std::set is
+    *  made empty by an erase operation,
+    *  https://gitlab.freedesktop.org/mesa/mesa/-/issues/7931
+    */
+   while(ii != ie && !dest->uses().empty()) {
       auto i = *ii;
       auto target_block_id = i->block_id();
 

Reply via email to