This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/64144] New: std::async can deadlock during thread exit
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 01 Dec 2014 19:25:22 +0000
- Subject: [Bug libstdc++/64144] New: std::async can deadlock during thread exit
- Auto-submitted: auto-generated
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.