From: Bart Van Assche Date: Thu, 28 Feb 2008 19:49:37 +0000 (+0000) Subject: Converted triple "Destroying locked mutex" messages into single messages. X-Git-Tag: svn/VALGRIND_3_4_0~1010 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d8c287376a886c76b056f0f1da0895a5ae6c05c2;p=thirdparty%2Fvalgrind.git Converted triple "Destroying locked mutex" messages into single messages. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7501 --- diff --git a/exp-drd/drd_mutex.c b/exp-drd/drd_mutex.c index 547bdfe403..16cd92ef36 100644 --- a/exp-drd/drd_mutex.c +++ b/exp-drd/drd_mutex.c @@ -36,6 +36,7 @@ // Local functions. +static void mutex_cleanup(struct mutex_info* p); static Bool mutex_is_locked(struct mutex_info* const p); static void mutex_destroy(struct mutex_info* const p); @@ -65,13 +66,29 @@ void mutex_initialize(struct mutex_info* const p, tl_assert(p->a1 == mutex); tl_assert(p->a2 == mutex + size); - p->cleanup = (void(*)(DrdClientobj*))&mutex_destroy; + p->cleanup = (void(*)(DrdClientobj*))&mutex_cleanup; p->mutex_type = mutex_type; p->recursion_count = 0; p->owner = DRD_INVALID_THREADID; vc_init(&p->vc, 0, 0); } +/** Deallocate the memory that was allocated by mutex_initialize(). */ +static void mutex_cleanup(struct mutex_info* p) +{ + if (mutex_is_locked(p)) + { + MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner }; + VG_(maybe_record_error)(VG_(get_running_tid)(), + MutexErr, + VG_(get_IP)(VG_(get_running_tid)()), + "Destroying locked mutex", + &MEI); + } + + vc_cleanup(&p->vc); +} + static struct mutex_info* mutex_get_or_allocate(const Addr mutex, @@ -152,24 +169,10 @@ static void mutex_destroy(struct mutex_info* const p) p->a1); } - if (mutex_is_locked(p)) - { - MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner }; - VG_(maybe_record_error)(VG_(get_running_tid)(), - MutexErr, - VG_(get_IP)(VG_(get_running_tid)()), - "Destroying locked mutex", - &MEI); - } - drd_clientobj_remove(p->a1); } -void mutex_pre_destroy(struct mutex_info* const p) -{ - return mutex_destroy(p); -} - +/** Called after pthread_mutex_destroy(). */ void mutex_post_destroy(const Addr mutex) { struct mutex_info* p; @@ -178,17 +181,7 @@ void mutex_post_destroy(const Addr mutex) tl_assert(p); if (p) { - if (mutex_get_recursion_count(mutex) > 0) - { - const ThreadId vg_tid = VG_(get_running_tid)(); - MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner }; - VG_(maybe_record_error)(vg_tid, - MutexErr, - VG_(get_IP)(vg_tid), - "Destroying locked mutex", - &MEI); - } - mutex_pre_destroy(p); + mutex_destroy(p); } } diff --git a/exp-drd/drd_mutex.h b/exp-drd/drd_mutex.h index ae6568b2c7..5c5c7a0507 100644 --- a/exp-drd/drd_mutex.h +++ b/exp-drd/drd_mutex.h @@ -42,7 +42,6 @@ struct mutex_info; void mutex_set_trace(const Bool trace_mutex); struct mutex_info* mutex_init(const Addr mutex, const SizeT size, const MutexT mutex_type); -void mutex_pre_destroy(struct mutex_info* const p); void mutex_post_destroy(const Addr mutex); struct mutex_info* mutex_get(const Addr mutex); void mutex_pre_lock(const Addr mutex, const SizeT size, const MutexT mutex_type); diff --git a/exp-drd/tests/tc04_free_lock.stderr.exp2 b/exp-drd/tests/tc04_free_lock.stderr.exp2 new file mode 100644 index 0000000000..768b25e597 --- /dev/null +++ b/exp-drd/tests/tc04_free_lock.stderr.exp2 @@ -0,0 +1,14 @@ + +Destroying locked mutex: address 0x........, recursion count 1, owner 1. + at 0x........: bar (tc04_free_lock.c:40) + by 0x........: (below main) (in /...libc...) + +Destroying locked mutex: address 0x........, recursion count 1, owner 1. + at 0x........: foo (tc04_free_lock.c:49) + by 0x........: (below main) (in /...libc...) + +Destroying locked mutex: address 0x........, recursion count 1, owner 1. + at 0x........: bar (tc04_free_lock.c:40) + by 0x........: (below main) (in /...libc...) + +ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0) diff --git a/exp-drd/tests/tc20_verifywrap.stderr.exp2 b/exp-drd/tests/tc20_verifywrap.stderr.exp2 index 4f9b520124..b5115ca839 100644 --- a/exp-drd/tests/tc20_verifywrap.stderr.exp2 +++ b/exp-drd/tests/tc20_verifywrap.stderr.exp2 @@ -16,14 +16,6 @@ Other segment end (thread 2) ---------------- pthread_mutex_lock et al ---------------- -Destroying locked mutex: address 0x........, recursion count 1, owner 1. - at 0x........: pthread_mutex_destroy (drd_intercepts.c:?) - by 0x........: main (tc20_verifywrap.c:102) - -Destroying locked mutex: address 0x........, recursion count 1, owner 1. - at 0x........: pthread_mutex_destroy (drd_intercepts.c:?) - by 0x........: main (tc20_verifywrap.c:102) - Destroying locked mutex: address 0x........, recursion count 1, owner 1. at 0x........: pthread_mutex_destroy (drd_intercepts.c:?) by 0x........: main (tc20_verifywrap.c:102) @@ -75,4 +67,4 @@ FIXME: can't figure out how to verify wrap of sem_post Destroying locked mutex: address 0x........, recursion count 1, owner 1. at 0x........: main (tc20_verifywrap.c:262) -ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 0 from 0) +ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)