Hello Julian,

Can you please apply the attached patch ? The attached patch fixes the
assertion failure triggered by the tc18_semabuse test on Fedora 8. The
fix consists of removing a tl_assert() statement. In this case this is
OK, because what the tl_assert() statement was checking is that
sem_post() did not report an error. The assert statement was there
because if sem_post() returns an error, in theory some real data races
can be suppressed. However, sem_post() only reports an error (EINVAL)
in case its argument is not a valid semaphore, so there is no danger
of suppressing a real data race.

Bart Van Assche.
Index: exp-drd/drd_semaphore.c
===================================================================
--- exp-drd/drd_semaphore.c     (revision 7405)
+++ exp-drd/drd_semaphore.c     (working copy)
@@ -165,12 +165,15 @@
 void semaphore_post_post(const DrdThreadId tid, const Addr semaphore,
                          const SizeT size, const Bool waited)
 {
-  /* Note: it is hard to implement the sem_post() wrapper correctly if */
-  /* sem_post() can return an error code. The reason is that this would */
-  /* require to detect whether sem_post() will fail before sem_post is */
-  /* called -- p->vc may only be modified if the sem_post() call will */
-  /* succeed. */
-  tl_assert(waited);
+  /* Note: it is hard to implement the sem_post() wrapper correctly in     */
+  /* case sem_post() returns an error code. This is because handling this  */
+  /* case correctly requires restoring the vector clock associated with    */
+  /* the semaphore to its original value here. In order to do that without */
+  /* introducing a race condition, extra locking has to be added around    */
+  /* each semaphore call. Such extra locking would have to be added in     */
+  /* drd_intercepts.c. However, it is hard to implement synchronization    */
+  /* in drd_intercepts.c in a portable way without calling already         */
+  /* redirected functions.                                                 */
 }
 
 void semaphore_thread_delete(const DrdThreadId threadid)
-------------------------------------------------------------------------
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