Added support for recognizing invalid mutexes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7497 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/exp-drd/drd_mutex.c b/exp-drd/drd_mutex.c
index 491d047..e45c6a6 100644
--- a/exp-drd/drd_mutex.c
+++ b/exp-drd/drd_mutex.c
@@ -251,12 +251,15 @@
*/
void mutex_pre_lock(const Addr mutex, const SizeT size, MutexT mutex_type)
{
- struct mutex_info* p = mutex_get(mutex);
+ struct mutex_info* p;
+
+ p = mutex_get(mutex);
if (p == 0)
{
mutex_init(mutex, size, mutex_type);
p = mutex_get(mutex);
}
+
tl_assert(p);
if (p->owner == thread_get_running_tid()
@@ -295,6 +298,16 @@
p ? p->owner : VG_INVALID_THREADID);
}
+ if (mutex_type == mutex_type_invalid_mutex)
+ {
+ GenericErrInfo GEI;
+ VG_(maybe_record_error)(VG_(get_running_tid)(),
+ GenericErr,
+ VG_(get_IP)(VG_(get_running_tid)()),
+ "Invalid mutex",
+ &GEI);
+ }
+
if (p == 0)
{
GenericErrInfo GEI;
@@ -368,6 +381,16 @@
p->owner);
}
+ if (mutex_type == mutex_type_invalid_mutex)
+ {
+ GenericErrInfo GEI;
+ VG_(maybe_record_error)(VG_(get_running_tid)(),
+ GenericErr,
+ VG_(get_IP)(VG_(get_running_tid)()),
+ "Invalid mutex",
+ &GEI);
+ }
+
if (p == 0)
{
GenericErrInfo GEI;
@@ -448,6 +471,8 @@
{
switch (mt)
{
+ case mutex_type_invalid_mutex:
+ return "invalid mutex";
case mutex_type_recursive_mutex:
return "recursive mutex";
case mutex_type_errorcheck_mutex: