This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/64144] New: std::async can deadlock during thread exit


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]