7 Replies Latest reply on Sep 23, 2016 7:20 AM by marklittle

    Could AtomicTransaction use nondeterministic locking?

    ochaloup

      I got few troubles coming from Coverity code static analysis tools and one of them is pointing out that AtomicTransaction [5] class could have nondeterministic locking behavior.

       

      The issue relates to class and methods
        * begin
        * suspend
        * rollback
        * commit

      lock_acquire: Acquiring lock `AtomicTransaction._theStatus`

      Bad choice of lock object (BAD_LOCK_OBJECT)3. lock_on_assigned_field:  Locking on the object referenced by field `_theStatus`. This lock  acquisition may race with another thread assigning to this field. The  contents of `_theStatus` may change while a thread is inside the  critical section, allowing two threads to enter the critical section  simultaneously.
         Instead of using `_theStatus` as a lock, create a final field of type Object which is only used as a lock.
      assign_to_field: The expression `_theStatus = current.get_status()`  assigns a new value to `_theStatus`, a field whose contents are used as a  lock. The locking behavior of this function may allow this assignment  to occur multiple times.

       

       

      To recap - the issue is caused by fact that `_theStatus` is reassigned to different instance which could cause wrong locking

       

      Could be this a real issue or the behavior is intentional?

       

      Thank you

      Ondra

       

       

      [5] https://github.com/jbosstm/narayana/blob/master/ArjunaJTS/jts/classes/com/arjuna/ats/jts/extensions/AtomicTransaction.java