[sanitizer] Relax pthread_join tests for different glibc versions (#194100)

New (2.43) glibc successfully joins already joined threads.
Probably result of
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=f7648bf44384118b6658ddcd741408fc4fbdd056
This commit is contained in:
Vitaly Buka
2026-04-24 19:10:33 -07:00
committed by GitHub
parent bd1c308117
commit 6dd373f8aa

View File

@@ -44,8 +44,10 @@ int main(int argc, char **argv) {
while (pthread_tryjoin_np(thread[1], &res))
sleep(1);
assert(~(uintptr_t)res == 1001);
assert(check_invalid_join ||
(pthread_tryjoin_np(thread[1], &res) == EBUSY));
if (!check_invalid_join) {
int err = pthread_tryjoin_np(thread[1], &res);
assert(err == EBUSY || err == 0);
}
}
{
@@ -54,15 +56,22 @@ int main(int argc, char **argv) {
while (pthread_timedjoin_np(thread[2], &res, &tm))
sleep(1);
assert(~(uintptr_t)res == 1002);
assert(check_invalid_join ||
(pthread_timedjoin_np(thread[2], &res, &tm) == ESRCH));
if (!check_invalid_join) {
res = nullptr;
int err = pthread_timedjoin_np(thread[2], &res, &tm);
assert(err == ESRCH || err == 0);
}
}
{
void *res;
assert(!pthread_join(thread[3], &res));
assert(~(uintptr_t)res == 1003);
assert(check_invalid_join || (pthread_join(thread[3], &res) == ESRCH));
if (!check_invalid_join) {
res = nullptr;
int err = pthread_join(thread[3], &res);
assert(err == ESRCH || err == 0);
}
}
return 0;