https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64144

            Bug ID: 64144
           Summary: std::async can deadlock during thread exit
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org

#include <future>

std::future<void> fut;

struct A {
  ~A() { fut.wait(); }
};

thread_local A a;

void f() { (void)&a; }

int main()
{
  fut = std::async(std::launch::async, f);
}


While the async thread is exiting the thread local destructor checks the status
of the future, detects it is ready, then blocks waiting for the thread to exit,
which won't happen until the destructor finishes.

Reply via email to