Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

adrian-prantl
Copy link
Collaborator

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.

by handling *all* errors in IRExecDiagnosticHandler.

rdar://124459751
@llvmbot
Copy link
Member

llvmbot commented Mar 12, 2024

@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/84992.diff

1 Files Affected:

  • (modified) lldb/source/Expression/IRExecutionUnit.cpp (+3-4)
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

@jimingham
Copy link
Collaborator

This makes sense to me. It still gives me the willies that there's exit's lurking in the llvm libraries, but so long as there are, we really do need to side-step them.

@adrian-prantl adrian-prantl merged commit c3eccf0 into llvm:main Mar 13, 2024
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Mar 13, 2024
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.

(cherry picked from commit c3eccf0)
adrian-prantl added a commit to swiftlang/llvm-project that referenced this pull request Mar 14, 2024
…25-Avoid-a-potential-exit-1-in-LLVMContext-diagnose-84992

[Cherry-pick into stable/20230725] Avoid a potential exit(1) in LLVMContext::diagnose()  (llvm#84992)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants