From: Julian Seward Date: Fri, 18 Jan 2008 07:42:01 +0000 (+0000) Subject: Regtest/stability changes for drd (Bart Van Assche) X-Git-Tag: svn/VALGRIND_3_4_0~1097 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=994193f9bbaecb46efb328568ab2d18b844a31e2;p=thirdparty%2Fvalgrind.git Regtest/stability changes for drd (Bart Van Assche) - Fix helgrind/tests/tc18_semabuse.c on glibc 2.7 (RedHat 8). - Fixed a glibc 2.7 specific assertion failure in exp-drd, namely one that was triggered when sem_post()'s return value is not zero. - exp-drd/test/matinv.c compiles now also on RedHat 7.3. Note: more work will be required to get exp-drd working correctly on RedHat 7.3. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7354 --- diff --git a/exp-drd/drd_clientreq.c b/exp-drd/drd_clientreq.c index ac4b04592c..a3d5287ffd 100644 --- a/exp-drd/drd_clientreq.c +++ b/exp-drd/drd_clientreq.c @@ -197,7 +197,7 @@ static Bool drd_handle_client_request(ThreadId tid, UWord* arg, UWord* ret) break; case VG_USERREQ__POST_SEM_POST: - drd_semaphore_post_post(thread_get_running_tid(), arg[1], arg[2]); + drd_semaphore_post_post(thread_get_running_tid(), arg[1], arg[2], arg[3]); break; case VG_USERREQ__BARRIER_INIT: diff --git a/exp-drd/drd_clientreq.h b/exp-drd/drd_clientreq.h index 4d7d4f3457..052a96ddec 100644 --- a/exp-drd/drd_clientreq.h +++ b/exp-drd/drd_clientreq.h @@ -100,7 +100,7 @@ enum { /* args: Addr sem, SizeT sem_size */ /* To notify the drd tool after a sem_post call. */ VG_USERREQ__POST_SEM_POST, - /* args: Addr sem, SizeT sem_size */ + /* args: Addr sem, SizeT sem_size, Bool waited */ /* To notify the drd tool of a pthread_barrier_init call. */ VG_USERREQ__BARRIER_INIT, diff --git a/exp-drd/drd_intercepts.c b/exp-drd/drd_intercepts.c index 675eec44d4..ad6746c4a2 100644 --- a/exp-drd/drd_intercepts.c +++ b/exp-drd/drd_intercepts.c @@ -773,12 +773,8 @@ PTH_FUNC(int, sem_postZa, // sem_post* VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_POST, sem, sizeof(*sem), 0, 0, 0); CALL_FN_W_W(ret, fn, sem); - assert(ret == 0); - if (ret == 0) - { - VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_POST, - sem, sizeof(*sem), 0, 0, 0); - } + VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_POST, + sem, sizeof(*sem), ret == 0, 0, 0); return ret; } diff --git a/exp-drd/drd_main.c b/exp-drd/drd_main.c index d4634ffc73..5353cfb253 100644 --- a/exp-drd/drd_main.c +++ b/exp-drd/drd_main.c @@ -512,9 +512,9 @@ void drd_semaphore_pre_post(const DrdThreadId tid, const Addr semaphore, } void drd_semaphore_post_post(const DrdThreadId tid, const Addr semaphore, - const SizeT size) + const SizeT size, const Bool waited) { - semaphore_post_post(tid, semaphore, size); + semaphore_post_post(tid, semaphore, size, waited); } diff --git a/exp-drd/drd_semaphore.c b/exp-drd/drd_semaphore.c index c5771964c3..89242a52e5 100644 --- a/exp-drd/drd_semaphore.c +++ b/exp-drd/drd_semaphore.c @@ -161,13 +161,16 @@ void semaphore_pre_post(const DrdThreadId tid, const Addr semaphore, /** Called after sem_post() finished successfully. */ void semaphore_post_post(const DrdThreadId tid, const Addr semaphore, - const SizeT size) + const SizeT size, const Bool waited) { - struct semaphore_info* p; + if (waited) + { + struct semaphore_info* p; - p = semaphore_get_or_allocate(semaphore, size); - thread_new_segment(tid); - vc_copy(&p->vc, thread_get_vc(tid)); + p = semaphore_get_or_allocate(semaphore, size); + thread_new_segment(tid); + vc_copy(&p->vc, thread_get_vc(tid)); + } } void semaphore_thread_delete(const DrdThreadId threadid) diff --git a/exp-drd/drd_semaphore.h b/exp-drd/drd_semaphore.h index 1562d342f3..0f68ff8d24 100644 --- a/exp-drd/drd_semaphore.h +++ b/exp-drd/drd_semaphore.h @@ -48,7 +48,7 @@ void semaphore_post_wait(const DrdThreadId tid, const Addr semaphore, void semaphore_pre_post(const DrdThreadId tid, const Addr semaphore, const SizeT size); void semaphore_post_post(const DrdThreadId tid, const Addr semaphore, - const SizeT size); + const SizeT size, const Bool waited); void semaphore_thread_delete(const DrdThreadId tid); void semaphore_stop_using_mem(const Addr a1, const Addr a2); diff --git a/exp-drd/drd_track.h b/exp-drd/drd_track.h index 4ffcd6e16d..5c452cfab5 100644 --- a/exp-drd/drd_track.h +++ b/exp-drd/drd_track.h @@ -45,7 +45,7 @@ void drd_semaphore_post_wait(const DrdThreadId tid, const Addr semaphore, void drd_semaphore_pre_post(const DrdThreadId tid, const Addr semaphore, const SizeT size); void drd_semaphore_post_post(const DrdThreadId tid, const Addr semaphore, - const SizeT size); + const SizeT size, const Bool waited); void drd_barrier_init(const Addr barrier, const SizeT size, const Word count); void drd_barrier_destroy(const Addr barrier); diff --git a/exp-drd/tests/matinv.c b/exp-drd/tests/matinv.c index dad8dd3ea0..fdd86993cd 100644 --- a/exp-drd/tests/matinv.c +++ b/exp-drd/tests/matinv.c @@ -10,6 +10,8 @@ /* Include directives. */ /***********************/ +#define _GNU_SOURCE + #include #include #include diff --git a/helgrind/tests/tc18_semabuse.c b/helgrind/tests/tc18_semabuse.c index 1fbc41928f..40c068bdea 100644 --- a/helgrind/tests/tc18_semabuse.c +++ b/helgrind/tests/tc18_semabuse.c @@ -33,8 +33,8 @@ int main ( void ) memset(&s1, 0x55, sizeof(s1)); r= sem_wait(&s1); /* assert(r != 0); */ - /* this really ought to fail, but it doesn't. */ - r= sem_post(&s1); assert(!r); + /* this only fails with glibc 2.7 and later. */ + r= sem_post(&s1); sem_destroy(&s1);