NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/52386: pthread(3) doesn't respect PTHREAD_DESTRUCTOR_ITERATIONS
>Number: 52386
>Category: lib
>Synopsis: pthread(3) doesn't respect PTHREAD_DESTRUCTOR_ITERATIONS
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jul 09 15:30:00 +0000 2017
>Originator: Kamil Rytarowski
>Release: NetBSD 8.99.1 amd64
>Organization:
TNF
>Environment:
NetBSD chieftec 8.99.1 NetBSD 8.99.1 (GENERIC) #5: Sat Jul 1 17:48:34 CEST 2017 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64
>Description:
PTHREAD_DESTRUCTOR_ITERATIONS is not respected as the maximum number of destructor iterations.
This has been caught by LLVM sanitizer tests. This breaks two tests.
compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cc
SanitizerCommon-Unit :: ./Sanitizer-i386-Test/SanitizerCommon.PthreadDestructorIterations
SanitizerCommon-Unit :: ./Sanitizer-x86_64-Test/SanitizerCommon.PthreadDestructorIterations
>How-To-Repeat:
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <pthread.h>
#include <limits.h>
static pthread_key_t key;
static bool destructor_executed;
void
destructor(void *arg)
{
uintptr_t iter = (uintptr_t)arg;
if (iter > 1) {
assert(0 == pthread_setspecific(key, (void*)(uintptr_t)(iter - 1)));
return;
}
destructor_executed = true;
}
void *
thread_func(void *arg)
{
return (void*)(uintptr_t)pthread_setspecific(key, arg);
}
static void
SpawnThread(int iteration)
{
destructor_executed = false;
pthread_t tid;
assert(0 == pthread_create(&tid, 0, thread_func, (void *)(uintptr_t)(iteration)));
void *retval;
assert(0 == pthread_join(tid, &retval));
assert(0 == retval);
}
int
main(int argc, char **argv)
{
pthread_key_create(&key, destructor);
SpawnThread(PTHREAD_DESTRUCTOR_ITERATIONS);
assert(destructor_executed == true);
SpawnThread(PTHREAD_DESTRUCTOR_ITERATIONS + 1);
assert(destructor_executed == false);
assert(0 == pthread_key_delete(key));
return 0;
}
>Fix:
N/A
Home |
Main Index |
Thread Index |
Old Index