[Lldb-commits] [lldb] c3eccf0 - Avoid a potential exit(1) in LLVMContext::diagnose() (#84992)

via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 13 08:53:17 PDT 2024


Author: Adrian Prantl
Date: 2024-03-13T08:53:13-07:00
New Revision: c3eccf03b365a705bc8dc043217478a82bc37a4d

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

LOG: Avoid a potential exit(1) in LLVMContext::diagnose()  (#84992)

by handling *all* errors in IRExecDiagnosticHandler. The function that
call this handles all unhandled errors with an `exit(1)`.

rdar://124459751

I don't really have a testcase for this, since the crash report I got
for this involved the Swift language plugin.

Added: 
    

Modified: 
    lldb/source/Expression/IRExecutionUnit.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp
index e4e131d70d4319..cb9bee8733e15d 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -212,18 +212,17 @@ struct IRExecDiagnosticHandler : public llvm::DiagnosticHandler {
   Status *err;
   IRExecDiagnosticHandler(Status *err) : err(err) {}
   bool handleDiagnostics(const llvm::DiagnosticInfo &DI) override {
-    if (DI.getKind() == llvm::DK_SrcMgr) {
+    if (DI.getSeverity() == llvm::DS_Error) {
       const auto &DISM = llvm::cast<llvm::DiagnosticInfoSrcMgr>(DI);
       if (err && err->Success()) {
         err->SetErrorToGenericError();
         err->SetErrorStringWithFormat(
-            "Inline assembly error: %s",
+            "IRExecution error: %s",
             DISM.getSMDiag().getMessage().str().c_str());
       }
-      return true;
     }
 
-    return false;
+    return true;
   }
 };
 } // namespace


        


More information about the lldb-commits mailing list