typedef enum
{
+ mutex_type_invalid_mutex = 0,
mutex_type_recursive_mutex = 1,
mutex_type_errorcheck_mutex = 2,
mutex_type_default_mutex = 3,
case PTHREAD_MUTEX_DEFAULT:
case PTHREAD_MUTEX_ADAPTIVE_NP:
return mutex_type_default_mutex;
-#if 0
- case -1:
- printf("Warning: changed mutex type from -1 into %d\n",
- mutex_type_default_mutex);
- return mutex_type_default_mutex;
-#endif
}
-#if 0
- printf("mutex->__data.__kind = %d\n", kind);
- assert(0);
-#endif
- return mutex_type_default_mutex;
+ return mutex_type_invalid_mutex;
}
static MutexT mutex_type(pthread_mutex_t* mutex)
*/
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()
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;
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;
{
switch (mt)
{
+ case mutex_type_invalid_mutex:
+ return "invalid mutex";
case mutex_type_recursive_mutex:
return "recursive mutex";
case mutex_type_errorcheck_mutex:
by 0x........: clone (in /...libc...)
Thread 1:
+Invalid mutex
+ at 0x........: pthread_mutex_unlock (drd_intercepts.c:?)
+ by 0x........: nearly_main (tc09_bad_unlock.c:41)
+ by 0x........: main (tc09_bad_unlock.c:49)
+
Not a mutex
at 0x........: pthread_mutex_unlock (drd_intercepts.c:?)
by 0x........: nearly_main (tc09_bad_unlock.c:41)
by 0x........: clone (in /...libc...)
Thread 1:
+Invalid mutex
+ at 0x........: pthread_mutex_unlock (drd_intercepts.c:?)
+ by 0x........: nearly_main (tc09_bad_unlock.c:41)
+ by 0x........: main (tc09_bad_unlock.c:50)
+
Not a mutex
at 0x........: pthread_mutex_unlock (drd_intercepts.c:?)
by 0x........: nearly_main (tc09_bad_unlock.c:41)
by 0x........: main (tc09_bad_unlock.c:50)
-ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)
+ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 0 from 0)
at 0x........: pthread_mutex_destroy (drd_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:102)
+Invalid mutex
+ at 0x........: pthread_mutex_unlock (drd_intercepts.c:?)
+ by 0x........: main (tc20_verifywrap.c:125)
+
Mutex not locked: address 0x........, recursion count 0, owner 0.
at 0x........: pthread_mutex_unlock (drd_intercepts.c:?)
by 0x........: main (tc20_verifywrap.c:125)
Destroying locked mutex: address 0x........, recursion count 1, owner 1.
at 0x........: main (tc20_verifywrap.c:261)
-ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)
+ERROR SUMMARY: 7 errors from 7 contexts (suppressed: 0 from 0)