================
@@ -91,29 +96,65 @@ class PolicyStack {
 
   Policy Current() const;
 
-  void Push(Policy policy) { m_stack.push_back(std::move(policy)); }
-
-  void Pop() {
-    assert(!m_stack.empty() && "can't pop the base policy");
-    m_stack.pop_back();
-  }
-
   void Dump(Stream &s) const;
 
-  /// RAII guard that pushes a policy on construction and pops on destruction.
+  /// RAII guard that pops a policy on destruction.
   class Guard {
+    friend class PolicyStack;
+
   public:
-    explicit Guard(Policy policy) { Get().Push(std::move(policy)); }
-    ~Guard() { Get().Pop(); }
+    ~Guard() {
+      if (m_active)
+        Get().Pop();
----------------
JDevlieghere wrote:

If i move this guard to another thread, this will pop from the new thread, 
corrupting its policy stack. I think we'll need to at least store the 
`std::this_thread::get_id()` (in an assert build?) to prevent someone from 
doing that accidentally because that would be a nightmare to debug. I think 
that should probably live in the policy as I can't imagine a situation where 
it's ever safe to push and pop from a different thread with our current design.

https://github.com/llvm/llvm-project/pull/195774
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to