Author: bart
Date: 2008-02-25 19:46:14 +0000 (Mon, 25 Feb 2008)
New Revision: 7461

Log:
Converted several assertions into error messages.

Modified:
   trunk/exp-drd/drd_mutex.c


Modified: trunk/exp-drd/drd_mutex.c
===================================================================
--- trunk/exp-drd/drd_mutex.c   2008-02-25 19:40:14 UTC (rev 7460)
+++ trunk/exp-drd/drd_mutex.c   2008-02-25 19:46:14 UTC (rev 7461)
@@ -110,6 +110,16 @@
   {
     if (s_mutex[i].mutex == 0)
     {
+      if (drd_is_any_suppressed(mutex, mutex + size))
+      {
+         MutexErrInfo MEI = { 0, 0, 0 };
+         VG_(maybe_record_error)(VG_(get_running_tid)(),
+                                 MutexErr,
+                                 VG_(get_IP)(VG_(get_running_tid)()),
+                                 "Not a mutex",
+                                 &MEI);
+         return 0;
+      }
       mutex_initialize(&s_mutex[i], mutex, size, mutex_type);
       drd_start_suppression(mutex, mutex + size,
                             mutex_get_typename(&s_mutex[i]));
@@ -220,7 +230,6 @@
 {
   const DrdThreadId drd_tid = VgThreadIdToDrdThreadId(VG_(get_running_tid)());
   struct mutex_info* const p = mutex_get_or_allocate(mutex, size, mutex_type);
-  const DrdThreadId last_owner = p->owner;
 
   if (s_trace_mutex)
   {
@@ -235,6 +244,17 @@
                  p ? p->owner : VG_INVALID_THREADID);
   }
 
+  if (p == 0)
+  {
+     MutexErrInfo MEI = { 0, 0, 0 };
+     VG_(maybe_record_error)(VG_(get_running_tid)(),
+                             MutexErr,
+                             VG_(get_IP)(VG_(get_running_tid)()),
+                             "Not a mutex",
+                             &MEI);
+     return 0;
+  }
+
   tl_assert(mutex_type == mutex_type_mutex
             || mutex_type == mutex_type_spinlock);
   tl_assert(p->mutex_type == mutex_type);
@@ -265,6 +285,8 @@
 
   if (p->recursion_count == 1)
   {
+     const DrdThreadId last_owner = p->owner;
+
     if (last_owner != drd_tid && last_owner != DRD_INVALID_THREADID)
       thread_combine_vc2(drd_tid, mutex_get_last_vc(mutex));
     thread_new_segment(drd_tid);
@@ -299,6 +321,17 @@
                  p->owner);
   }
 
+  if (p == 0 || p->owner == DRD_INVALID_THREADID)
+  {
+     MutexErrInfo MEI = { 0, 0, 0 };
+     VG_(maybe_record_error)(vg_tid,
+                             MutexErr,
+                             VG_(get_IP)(vg_tid),
+                             "Not a mutex",
+                             &MEI);
+     return 0;
+  }
+
   tl_assert(p);
   tl_assert(p->mutex_type == mutex_type);
   tl_assert(p->owner != DRD_INVALID_THREADID);
@@ -363,7 +396,6 @@
 Bool mutex_is_locked_by(const Addr mutex, const DrdThreadId tid)
 {
   struct mutex_info* const p = mutex_get(mutex);
-  tl_assert(p);
   if (p)
   {
     return (p->recursion_count > 0 && p->owner == tid);


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to