From: Jacques Pienaar Date: Wed, 21 Dec 2022 19:43:03 +0000 (-0800) Subject: [mlir] Clear running passes in crashreporter X-Git-Tag: upstream/17.0.6~22928 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=383329b3a8881bda8d5989439d37b75a5f732f5f;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/mlir/lib/Pass/PassCrashRecovery.cpp b/mlir/lib/Pass/PassCrashRecovery.cpp index a98a1f1..67e4047 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