https://llvm.org/bugs/show_bug.cgi?id=24692

            Bug ID: 24692
           Summary: promise/future deadlock
           Product: libc++
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

The following test case results in a deadlock:

    #include <chrono>
    #include <future>
    #include <iostream>
    #include <utility>

    template <typename T>
    struct weird {
      std::future<weird<T>> f;

      explicit weird(std::future<weird<T>> f) : f(std::move(f)) {}

      weird(weird&& other)
        : f(std::move(other.f))
      {
        if (f.wait_for(std::chrono::seconds(1)) == std::future_status::timeout)
{
          std::cout << "Moving but the future is not ready yet\n";
        }
      }
    };

    int main() {
      std::promise<weird<int>> p;
      weird<int> w(p.get_future());
      p.set_value(std::move(w));
    }

This is caused by executing arbitrary user code under a lock.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to