On 13/08/20 18:15 -0400, Lewis Hyatt via Libstdc++ wrote: >Hello- > >The attached patch was discussed briefly on PR 54185 here: >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54185#c14 >The test case for this PR sometimes fails due to random failures in >pthread_create() that are not related to the original PR. This patch fixes >it up by ignoring those failures. The test case was designed to repeat the >same test 1000 times to attempt to reproduce a race condition, so I think is >OK if some of those iterations are simply skipped. > >Thanks for taking a look at it; I can commit it if it makes sense. > >-Lewis >libstdc++: testsuite: Address random failure in pthread_create() [PR54185] > >The test for this PR calls pthread_create() many times in a row, which may fail >with EAGAIN sometimes. Avoid generating a test failure in this case. > >libstdc++-v3/ChangeLog: > > PR libstdc++/54185 > * testsuite/30_threads/condition_variable/54185.cc: Make test robust > to random pthread_create() failures. Thanks for the patch. It certainly looks reasonable, but I wonder if the attached version wouldn't be (very slightly) better. The difference is that instead of just giving up at the first EAGAIN we keep trying. This way we might be able to create a few more threads before the loop finishes. If we still keep failing, it works the same. I've also added a check that the failures are due to EAGAIN, and we'll still terminate if there's some other problem. I'm assuming that your failures are EAGAIN. Do you know why that's happening? Does your system a low value for RLIMIT_NPROC or something? The failures for that testcase on AIX appear to be different. It just segfaults after destroying the condition_variable, which probably means there's a POSIX conformance issue in AIX's pthread_cond_t.