JDevlieghere created this revision.
JDevlieghere added a reviewer: vsk.
JDevlieghere requested review of this revision.

During active replay, the `::Initialize` call is replayed like any other SB API
call and the return value is ignored. Since we can't intercept this, we
terminate here before the uninitialized debugger inevitably crashes.


https://reviews.llvm.org/D90987

Files:
  lldb/source/API/SystemInitializerFull.cpp


Index: lldb/source/API/SystemInitializerFull.cpp
===================================================================
--- lldb/source/API/SystemInitializerFull.cpp
+++ lldb/source/API/SystemInitializerFull.cpp
@@ -17,6 +17,7 @@
 #include "lldb/Target/ProcessTrace.h"
 #include "lldb/Utility/Timer.h"
 #include "llvm/Support/TargetSelect.h"
+#include "lldb/Utility/Reproducer.h"
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wglobal-constructors"
@@ -24,6 +25,7 @@
 #pragma clang diagnostic pop
 
 #include <string>
+#include <cstdlib>
 
 #define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p)
 #include "Plugins/Plugins.def"
@@ -34,8 +36,16 @@
 SystemInitializerFull::~SystemInitializerFull() = default;
 
 llvm::Error SystemInitializerFull::Initialize() {
-  if (auto e = SystemInitializerCommon::Initialize())
-    return e;
+  llvm::Error error = SystemInitializerCommon::Initialize();
+  if (error) {
+    // During active replay, the ::Initialize call is replayed like any other
+    // SB API call and the return value is ignored. Since we can't intercept
+    // this, we terminate here before the uninitialized debugger inevitably
+    // crashes.
+    if (repro::Reproducer::Instance().IsReplaying())
+      std::_Exit(EXIT_FAILURE);
+    return error;
+  }
 
   // Initialize LLVM and Clang
   llvm::InitializeAllTargets();


Index: lldb/source/API/SystemInitializerFull.cpp
===================================================================
--- lldb/source/API/SystemInitializerFull.cpp
+++ lldb/source/API/SystemInitializerFull.cpp
@@ -17,6 +17,7 @@
 #include "lldb/Target/ProcessTrace.h"
 #include "lldb/Utility/Timer.h"
 #include "llvm/Support/TargetSelect.h"
+#include "lldb/Utility/Reproducer.h"
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wglobal-constructors"
@@ -24,6 +25,7 @@
 #pragma clang diagnostic pop
 
 #include <string>
+#include <cstdlib>
 
 #define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p)
 #include "Plugins/Plugins.def"
@@ -34,8 +36,16 @@
 SystemInitializerFull::~SystemInitializerFull() = default;
 
 llvm::Error SystemInitializerFull::Initialize() {
-  if (auto e = SystemInitializerCommon::Initialize())
-    return e;
+  llvm::Error error = SystemInitializerCommon::Initialize();
+  if (error) {
+    // During active replay, the ::Initialize call is replayed like any other
+    // SB API call and the return value is ignored. Since we can't intercept
+    // this, we terminate here before the uninitialized debugger inevitably
+    // crashes.
+    if (repro::Reproducer::Instance().IsReplaying())
+      std::_Exit(EXIT_FAILURE);
+    return error;
+  }
 
   // Initialize LLVM and Clang
   llvm::InitializeAllTargets();
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to