[Bug 1844022] Re: pthread_setattr_default_np race condition with pthread_create.

2019-10-16 Thread Maxim Egorushkin
> No, the race condition is in your stack size test (which is written incorrectly), not in the stack creation. You are right, the test should use pthread_getattr_np instead of pthread_attr_init. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed

[Bug 1844022] Re: pthread_setattr_default_np race condition with pthread_create.

2019-10-16 Thread Florian Weimer
No, the race condition is in your stack size test (which is written incorrectly), not in the stack creation. However, this code is inherently race-prone anyway: pthread_attr_t attr; pthread_setattr_default_np() std::thread t(...); You just need something else in the process using std::thread

[Bug 1844022] Re: pthread_setattr_default_np race condition with pthread_create.

2019-09-16 Thread Maxim Egorushkin
> 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;

[Bug 1844022] Re: pthread_setattr_default_np race condition with pthread_create.

2019-09-16 Thread Florian Weimer
I assume the code in another_thread attempts to obtain the size of the current thread. But the code just reads back the default stack size, which may have changed due to the set_default_thread_stack_size call. One way to obtain the size of the current thread stack is this call: if(int err