case MutexErr: {
MutexErrInfo* p = (MutexErrInfo*)(VG_(get_error_extra)(e));
tl_assert(p);
- VG_(message)(Vg_UserMsg,
- "%s: mutex 0x%lx, recursion count %d, owner %d.",
- VG_(get_error_string)(e),
- p->mutex,
- p->recursion_count,
- p->owner);
+ if (p->recursion_count >= 0)
+ {
+ VG_(message)(Vg_UserMsg,
+ "%s: mutex 0x%lx, recursion count %d, owner %d.",
+ VG_(get_error_string)(e),
+ p->mutex,
+ p->recursion_count,
+ p->owner);
+ }
+ else
+ {
+ VG_(message)(Vg_UserMsg,
+ "%s: mutex 0x%lx.",
+ VG_(get_error_string)(e),
+ p->mutex);
+ }
VG_(pp_ExeContext)(VG_(get_error_where)(e));
break;
}
/** Deallocate the memory that was allocated by mutex_initialize(). */
static void mutex_cleanup(struct mutex_info* p)
{
+ tl_assert(p);
+
if (s_trace_mutex)
{
VG_(message)(Vg_UserMsg,
p->last_locked_segment = 0;
}
+static void not_a_mutex(const Addr mutex)
+{
+ MutexErrInfo MEI = { mutex, -1, DRD_INVALID_THREADID };
+ VG_(maybe_record_error)(VG_(get_running_tid)(),
+ MutexErr,
+ VG_(get_IP)(VG_(get_running_tid)()),
+ "Not a mutex",
+ &MEI);
+}
+
static
struct mutex_info*
mutex_get_or_allocate(const Addr mutex, const MutexT mutex_type)
if (clientobj_present(mutex, mutex + 1))
{
- GenericErrInfo GEI;
- VG_(maybe_record_error)(VG_(get_running_tid)(),
- GenericErr,
- VG_(get_IP)(VG_(get_running_tid)()),
- "Not a mutex",
- &GEI);
+ not_a_mutex(mutex);
return 0;
}
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)()),
- "Not a mutex",
- &GEI);
+ not_a_mutex(mutex);
return 0;
}
p = mutex_get(mutex);
if (p == 0)
{
- GenericErrInfo GEI;
- VG_(maybe_record_error)(VG_(get_running_tid)(),
- GenericErr,
- VG_(get_IP)(VG_(get_running_tid)()),
- "Not a mutex",
- &GEI);
+ not_a_mutex(mutex);
return;
}
"[%d/%d] pre_mutex_lock %s 0x%lx rc %d owner %d",
VG_(get_running_tid)(),
thread_get_running_tid(),
- mutex_get_typename(p),
+ p ? mutex_get_typename(p) : "(?)",
mutex,
p ? p->recursion_count : -1,
p ? p->owner : DRD_INVALID_THREADID);
if (p == 0)
{
- GenericErrInfo GEI;
- VG_(maybe_record_error)(VG_(get_running_tid)(),
- GenericErr,
- VG_(get_IP)(VG_(get_running_tid)()),
- "Not a mutex",
- &GEI);
+ not_a_mutex(mutex);
return;
}
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)()),
- "Not a mutex",
- &GEI);
+ not_a_mutex(mutex);
return;
}
"[%d/%d] mutex_unlock %s 0x%lx rc %d",
vg_tid,
drd_tid,
- p ? mutex_get_typename(p) : "?",
+ p ? mutex_get_typename(p) : "(?)",
mutex,
p ? p->recursion_count : 0);
}
if (p == 0 || mutex_type == mutex_type_invalid_mutex)
{
- GenericErrInfo GEI;
- VG_(maybe_record_error)(vg_tid,
- GenericErr,
- VG_(get_IP)(vg_tid),
- "Not a mutex",
- &GEI);
+ not_a_mutex(mutex);
return;
}
by 0x........: clone (in /...libc...)
Thread 1:
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
by 0x........: nearly_main (tc09_bad_unlock.c:41)
by 0x........: main (tc09_bad_unlock.c:49)
by 0x........: clone (in /...libc...)
Thread 1:
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
by 0x........: nearly_main (tc09_bad_unlock.c:41)
by 0x........: main (tc09_bad_unlock.c:50)
---------------- pthread_mutex_lock et al ----------------
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:92)
at 0x........: pthread_mutex_destroy (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:102)
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_lock (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:108)
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_trylock (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:116)
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_timedlock (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:121)
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:125)
[1/1] mutex_init invalid mutex 0x........
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:92)
[1/1] mutex_init mutex 0x........
by 0x........: main (tc20_verifywrap.c:102)
[1/1] pre_mutex_lock invalid mutex 0x........ rc 0 owner 0
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_lock (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:108)
[1/1] post_mutex_lock invalid mutex 0x........ rc 0 owner 0
[1/1] pre_mutex_lock invalid mutex 0x........ rc 0 owner 0
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_trylock (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:116)
[1/1] post_mutex_lock invalid mutex 0x........ rc 0 owner 0
[1/1] pre_mutex_lock invalid mutex 0x........ rc 0 owner 0
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_timedlock (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:121)
[1/1] post_mutex_lock invalid mutex 0x........ rc 0 owner 0
[1/1] mutex_unlock invalid mutex 0x........ rc 0
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:125)
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_cond_wait* (drd_pthread_intercepts.c:?)
by 0x........: main (tc23_bogus_condwait.c:69)
at 0x........: pthread_cond_wait* (drd_pthread_intercepts.c:?)
by 0x........: main (tc23_bogus_condwait.c:72)
-Not a mutex
+Not a mutex: mutex 0x.........
at 0x........: pthread_cond_wait* (drd_pthread_intercepts.c:?)
by 0x........: main (tc23_bogus_condwait.c:75)