[Mlir-commits] [mlir] 383329b - [mlir] Clear running passes in crashreporter

Jacques Pienaar llvmlistbot at llvm.org
Wed Dec 21 11:43:09 PST 2022


Author: Jacques Pienaar
Date: 2022-12-21T11:43:03-08:00
New Revision: 383329b3a8881bda8d5989439d37b75a5f732f5f

URL: https://github.com/llvm/llvm-project/commit/383329b3a8881bda8d5989439d37b75a5f732f5f
DIFF: https://github.com/llvm/llvm-project/commit/383329b3a8881bda8d5989439d37b75a5f732f5f.diff

LOG: [mlir] Clear running passes in crashreporter

Clear active contexts and running passes whenever finalizing crash
report message. Ran into segfault where a failure in dynamic pipeline
resulted in querying a pass whose passmanager had already been destroyed
come time for creating summary of running passes. Conservatively clear
both running states as I don't think there is recovery intended from
pass pipeline failure.

Additionally restrict to one reproducer per report - else we end up
clobbering the same reproducer file over and over again. So instead of
ending with last reproducer we now end up with the first reproducer
while not creating and clobbering reproducers over and over again.

Differential Revision: https://reviews.llvm.org/D140488

Added: 
    

Modified: 
    mlir/lib/Pass/PassCrashRecovery.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Pass/PassCrashRecovery.cpp b/mlir/lib/Pass/PassCrashRecovery.cpp
index a98a1f1f6e47..67e404793c09 100644
--- a/mlir/lib/Pass/PassCrashRecovery.cpp
+++ b/mlir/lib/Pass/PassCrashRecovery.cpp
@@ -258,6 +258,8 @@ void PassCrashReproducerGenerator::finalize(Operation *rootOp,
                             formatPassOpReproducerMessage(note, value);
                           });
     note << "]: " << description;
+    impl->runningPasses.clear();
+    impl->activeContexts.clear();
     return;
   }
 
@@ -278,6 +280,7 @@ void PassCrashReproducerGenerator::finalize(Operation *rootOp,
   note << ": " << description;
 
   impl->activeContexts.clear();
+  impl->runningPasses.clear();
 }
 
 void PassCrashReproducerGenerator::prepareReproducerFor(Pass *pass,
@@ -359,12 +362,18 @@ struct CrashReproducerInstrumentation : public PassInstrumentation {
   }
 
   void runAfterPassFailed(Pass *pass, Operation *op) override {
+    // Only generate one reproducer per crash reproducer instrumentation.
+    if (alreadyFailed)
+      return;
+
+    alreadyFailed = true;
     generator.finalize(op, /*executionResult=*/failure());
   }
 
 private:
   /// The generator used to create crash reproducers.
   PassCrashReproducerGenerator &generator;
+  bool alreadyFailed = false;
 };
 } // namespace
 


        


More information about the Mlir-commits mailing list