std::async() execute std::~thread() before calling std::shared_future<>::get() from calling thread. This causing the generation of std::terminate and crashing the application. Getting this issue on iOS version 10.*.
Below is my code snippet:
std::shared_future<> foo(int x)
{
std::shared_future<> f = std::async(std::launch::async,
[this, x](){});
return f;
}
void caller()
{
std::shared_future<> future = foo(10);
std::future_status result = future.wait_for(std::chrono::milliseconds(30000ms));
if (result == std::future_status::ready)
{
result = future.get();
}
}
Dump stack:
0 libsystem_kernel.dylib 0x000000018eeb2014 __pthread_kill + 8
1 libsystem_pthread.dylib 0x000000018ef7a450 pthread_kill + 108
2 libsystem_c.dylib 0x000000018ee263e0 abort + 136
3 libc++abi.dylib 0x000000018e8f12d4 abort_message + 128
4 libc++abi.dylib 0x000000018e90ebc0 default_terminate_handler() + 44
5 ReactEmbeddedFramework 0x00000001014d7698 BITCrashUncaughtCXXTerminateHandler() (BITCrashCXXExceptionHandler.mm:188)
6 libc++abi.dylib 0x000000018e90b66c std::__terminate(void (*)()) + 12
7 libc++abi.dylib 0x000000018e90b6e4 std::terminate() + 68
8 libc++.1.dylib 0x000000018e8e17e0 std::__1::thread::~thread() + 20
9 0x0000000101e3b540foo
This issue is occurring on iOS version 10.*.*. So Is it know issue with version 10+?