Guy,
There's a related potential bug (haven't worked through the details)
based on the use of a counter to track the number of locks that are
acquired. A lock that is "acquired" twice is, of course, not locked
the
second time, but the counter is incremented twice. If the
transaction
aborts, then it might try to unlock the same lock twice. Some bad
interleavings with a concurrent writer are technically possible.
In RSTM, we use a separate lock set. Only a successful lock acquire
leads to the lock being added to the lock set, and then to release
all
locks (as in the case Joe mentioned below, but also in the case of
aborts), we iterate through the lock set, not the write set. In
addition to the code being easier to understand w.r.t. correctness in
the face of hashing, this approach avoids hashing writeset entries
multiple times. In C++, it proved to be faster, but in Java, the
overheads may tip the scales in favor of a counter-based approach,
such
as that currently in DeuceSTM's TL2 implementation.
- Mike Spear