Comment 2 for bug 1844022

Revision history for this message
Maxim Egorushkin (max0x7ba) wrote :

> I assume the code in another_thread attempts to obtain the size of the current thread.

The intention is to use pthread_setattr_default_np followed by a call to std::thread contructor, because the latter doesn't allow specifying the thread attribute.

So, instead of:

pthread_attr_t attr;
<initialize attr>
pthread_create(..., &attr, ...)

Use:

pthread_attr_t attr;
<initialize attr>
pthread_setattr_default_np(&attr)
std::thread t(...);

But this race condition prevents such usage of pthread_setattr_default_np.