Change the semantics of ANNOTATE_HAPPENS_BEFORE from 'overwrite' to
'add' behaviour, w.r.t. any h-b edges associated with the
synchronisation object prior to the call.  This brings the behaviour
into line with DRD and TSan, and is required for correct annotation of
thread safe reference counting.  It fixes #243935 -- at least, the
original bug as discussed in comments 0 and 2.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11624 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/helgrind/helgrind.h b/helgrind/helgrind.h
index 2c30a5a..23eb4b7 100644
--- a/helgrind/helgrind.h
+++ b/helgrind/helgrind.h
@@ -433,13 +433,15 @@
 
 /* ----------------------------------------------------------------
    Create completely arbitrary happens-before edges between threads.
-   If thread T1 does ANNOTATE_HAPPENS_BEFORE(obj) and later (w.r.t.
-   some notional global clock for the computation) thread T2 does
-   ANNOTATE_HAPPENS_AFTER(obj), then Helgrind will regard all memory
-   accesses done by T1 before the ..BEFORE.. call as happening-before
-   all memory accesses done by T2 after the ..AFTER.. call.  Hence
-   Helgrind won't complain about races if T2's accesses afterwards are
-   to the same locations as T1's accesses before.
+
+   If threads T1 .. Tn all do ANNOTATE_HAPPENS_BEFORE(obj) and later
+   (w.r.t. some notional global clock for the computation) thread Tm
+   does ANNOTATE_HAPPENS_AFTER(obj), then Helgrind will regard all
+   memory accesses done by T1 .. Tn before the ..BEFORE.. call as
+   happening-before all memory accesses done by Tm after the
+   ..AFTER.. call.  Hence Helgrind won't complain about races if Tm's
+   accesses afterwards are to the same locations as accesses before by
+   any of T1 .. Tn.
 
    OBJ is a machine word (unsigned long, or void*), is completely
    arbitrary, and denotes the identity of some synchronisation object
@@ -453,6 +455,9 @@
    take the time to understand these two.  They form the very essence
    of describing arbitrary inter-thread synchronisation events to
    Helgrind.  You can get a long way just with them alone.
+
+   See also, extensive discussion on semantics of this in 
+   https://bugs.kde.org/show_bug.cgi?id=243935
    ----------------------------------------------------------------
 */
 #define ANNOTATE_HAPPENS_BEFORE(obj) \