mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-15670 - unit.my_atomic failed in buildbot with Signal 11 thrown
Workaround glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20116 by making unittest threads joinable. It makes code better anyway.
This commit is contained in:
@ -48,9 +48,6 @@ pthread_handler_t test_lf_pinbox(void *arg)
|
|||||||
pins= lf_pinbox_get_pins(&lf_allocator.pinbox);
|
pins= lf_pinbox_get_pins(&lf_allocator.pinbox);
|
||||||
}
|
}
|
||||||
lf_pinbox_put_pins(pins);
|
lf_pinbox_put_pins(pins);
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
if (!--running_threads) pthread_cond_signal(&cond);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
|
|
||||||
if (with_my_thread_init)
|
if (with_my_thread_init)
|
||||||
my_thread_end();
|
my_thread_end();
|
||||||
@ -105,7 +102,6 @@ pthread_handler_t test_lf_alloc(void *arg)
|
|||||||
bad|= lf_allocator.mallocs - lf_alloc_pool_count(&lf_allocator);
|
bad|= lf_allocator.mallocs - lf_alloc_pool_count(&lf_allocator);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (!--running_threads) pthread_cond_signal(&cond);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
|
|
||||||
if (with_my_thread_init)
|
if (with_my_thread_init)
|
||||||
@ -159,7 +155,6 @@ pthread_handler_t test_lf_hash(void *arg)
|
|||||||
lf_hash.size, inserts);
|
lf_hash.size, inserts);
|
||||||
bad|= lf_hash.count;
|
bad|= lf_hash.count;
|
||||||
}
|
}
|
||||||
if (!--running_threads) pthread_cond_signal(&cond);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
if (with_my_thread_init)
|
if (with_my_thread_init)
|
||||||
my_thread_end();
|
my_thread_end();
|
||||||
|
@ -35,9 +35,6 @@ pthread_handler_t test_atomic_add(void *arg)
|
|||||||
my_atomic_add32(&bad, -x);
|
my_atomic_add32(&bad, -x);
|
||||||
my_atomic_rwlock_wrunlock(&rwl);
|
my_atomic_rwlock_wrunlock(&rwl);
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
if (!--running_threads) pthread_cond_signal(&cond);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,13 +55,6 @@ pthread_handler_t test_atomic_add64(void *arg)
|
|||||||
my_atomic_add64(&a64, -x);
|
my_atomic_add64(&a64, -x);
|
||||||
my_atomic_rwlock_wrunlock(&rwl);
|
my_atomic_rwlock_wrunlock(&rwl);
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
if (!--running_threads)
|
|
||||||
{
|
|
||||||
bad= (a64 != 0);
|
|
||||||
pthread_cond_signal(&cond);
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,9 +98,6 @@ pthread_handler_t test_atomic_fas(void *arg)
|
|||||||
my_atomic_add32(&bad, -x);
|
my_atomic_add32(&bad, -x);
|
||||||
my_atomic_rwlock_wrunlock(&rwl);
|
my_atomic_rwlock_wrunlock(&rwl);
|
||||||
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
if (!--running_threads) pthread_cond_signal(&cond);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,9 +127,6 @@ pthread_handler_t test_atomic_cas(void *arg)
|
|||||||
my_atomic_rwlock_wrunlock(&rwl);
|
my_atomic_rwlock_wrunlock(&rwl);
|
||||||
} while (!ok) ;
|
} while (!ok) ;
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
if (!--running_threads) pthread_cond_signal(&cond);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,6 +162,7 @@ void do_tests()
|
|||||||
}
|
}
|
||||||
a64=0;
|
a64=0;
|
||||||
test_concurrently("my_atomic_add64", test_atomic_add64, THREADS, CYCLES);
|
test_concurrently("my_atomic_add64", test_atomic_add64, THREADS, CYCLES);
|
||||||
|
bad= (a64 != 0);
|
||||||
|
|
||||||
my_atomic_rwlock_destroy(&rwl);
|
my_atomic_rwlock_destroy(&rwl);
|
||||||
}
|
}
|
||||||
|
@ -20,35 +20,34 @@
|
|||||||
#include <tap.h>
|
#include <tap.h>
|
||||||
|
|
||||||
volatile uint32 bad;
|
volatile uint32 bad;
|
||||||
pthread_attr_t thr_attr;
|
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
pthread_cond_t cond;
|
|
||||||
uint running_threads;
|
|
||||||
|
|
||||||
void do_tests();
|
void do_tests();
|
||||||
|
|
||||||
void test_concurrently(const char *test, pthread_handler handler, int n, int m)
|
void test_concurrently(const char *test, pthread_handler handler, int n, int m)
|
||||||
{
|
{
|
||||||
pthread_t t;
|
pthread_t *threads= malloc(n * sizeof(pthread_t));
|
||||||
|
int i;
|
||||||
ulonglong now= my_interval_timer();
|
ulonglong now= my_interval_timer();
|
||||||
|
|
||||||
|
assert(threads);
|
||||||
bad= 0;
|
bad= 0;
|
||||||
|
|
||||||
diag("Testing %s with %d threads, %d iterations... ", test, n, m);
|
diag("Testing %s with %d threads, %d iterations... ", test, n, m);
|
||||||
for (running_threads= n ; n ; n--)
|
for (i= n; i; i--)
|
||||||
{
|
{
|
||||||
if (pthread_create(&t, &thr_attr, handler, &m) != 0)
|
if (pthread_create(&threads[i], 0, handler, &m) != 0)
|
||||||
{
|
{
|
||||||
diag("Could not create thread");
|
diag("Could not create thread");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
while (running_threads)
|
for (i= n; i; i--)
|
||||||
pthread_cond_wait(&cond, &mutex);
|
pthread_join(threads[i], 0);
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
|
|
||||||
now= my_interval_timer() - now;
|
now= my_interval_timer() - now;
|
||||||
|
free(threads);
|
||||||
ok(!bad, "tested %s in %g secs (%d)", test, ((double)now)/1e9, bad);
|
ok(!bad, "tested %s in %g secs (%d)", test, ((double)now)/1e9, bad);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,9 +59,6 @@ int main(int argc __attribute__((unused)), char **argv)
|
|||||||
DBUG_SET_INITIAL(argv[1]);
|
DBUG_SET_INITIAL(argv[1]);
|
||||||
|
|
||||||
pthread_mutex_init(&mutex, 0);
|
pthread_mutex_init(&mutex, 0);
|
||||||
pthread_cond_init(&cond, 0);
|
|
||||||
pthread_attr_init(&thr_attr);
|
|
||||||
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
|
|
||||||
|
|
||||||
#ifdef MY_ATOMIC_MODE_RWLOCKS
|
#ifdef MY_ATOMIC_MODE_RWLOCKS
|
||||||
#if defined(HPUX11) || defined(__POWERPC__) /* showed to be very slow (scheduler-related) */
|
#if defined(HPUX11) || defined(__POWERPC__) /* showed to be very slow (scheduler-related) */
|
||||||
@ -79,16 +75,7 @@ int main(int argc __attribute__((unused)), char **argv)
|
|||||||
|
|
||||||
do_tests();
|
do_tests();
|
||||||
|
|
||||||
/*
|
|
||||||
workaround until we know why it crashes randomly on some machine
|
|
||||||
(BUG#22320).
|
|
||||||
*/
|
|
||||||
#ifdef NOT_USED
|
|
||||||
sleep(2);
|
|
||||||
#endif
|
|
||||||
pthread_mutex_destroy(&mutex);
|
pthread_mutex_destroy(&mutex);
|
||||||
pthread_cond_destroy(&cond);
|
|
||||||
pthread_attr_destroy(&thr_attr);
|
|
||||||
my_end(0);
|
my_end(0);
|
||||||
return exit_status();
|
return exit_status();
|
||||||
}
|
}
|
||||||
|
@ -136,10 +136,8 @@ retry:
|
|||||||
pthread_mutex_unlock(&lock);
|
pthread_mutex_unlock(&lock);
|
||||||
pthread_mutex_unlock(& thds[id].lock);
|
pthread_mutex_unlock(& thds[id].lock);
|
||||||
wt_thd_destroy(& thds[id].thd);
|
wt_thd_destroy(& thds[id].thd);
|
||||||
|
|
||||||
if (!--running_threads) /* now, signal when everybody is done with deinit */
|
|
||||||
pthread_cond_signal(&cond);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
|
|
||||||
DBUG_PRINT("wt", ("exiting"));
|
DBUG_PRINT("wt", ("exiting"));
|
||||||
my_thread_end();
|
my_thread_end();
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user