pthread_barrier_wait can return either PTHREAD_BARRIER_SERIAL_THREAD
or 0. Posix makes no guarantees about which thread return the unique
value.
Additionally, pthread_join was not called despite seemingly checking
for the error.
If a call to the set*id functions fails in a multi-threaded program,
the abort introduced in commit 13f7fe35ae
was triggered.
We address by checking that all calls to set*id on all threads give
the same result, and only abort if we see success followed by failure
(or vice versa).