https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54185
Lewis Hyatt <lhyatt at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lhyatt at gmail dot com --- Comment #14 from Lewis Hyatt <lhyatt at gmail dot com> --- Created attachment 49061 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49061&action=edit Fix for random pthread_create() failures Hello- I have problems with the test case for this bug (libstdc++-v3/testsuite/30_threads/condition_variable/54185.cc) failing randomly. It happens more often with parallel make, and especially if running the testsuite as a whole more than once in parallel. On my system at least (x86-64, Ubuntu 18), it seems that pthread_create() will return EAGAIN sometimes in any loop like the one this testcase uses: for(int i = 0; i != 1000; ++i) {pthread_create(...); pthread_join(...);} If such a loop is running in 3 or more processes in parallel it happens more than 50% of the time. I am not sure what global resource gets used up, it happens even if ulimit -a shows nothing being limited like processes or memory. The attached patch fixes the failures for me; if thread creation fails, it just gives up and moves on to the next iteration instead. I had to convert the cond->wait() to the predicate form since it becomes possible for the notify to take place prior to all threads calling wait. I can submit this to gcc-patches if it makes sense to you? Thanks... -Lewis