[jbossts-issues] [JBoss JIRA] (JBTM-2756) Static code analysis: nondeterministic locking behavior at ThreadAssociations#removeAll
Ondra Chaloupka (JIRA)
issues at jboss.org
Tue Sep 20 09:42:00 EDT 2016
Ondra Chaloupka created JBTM-2756:
-------------------------------------
Summary: Static code analysis: nondeterministic locking behavior at ThreadAssociations#removeAll
Key: JBTM-2756
URL: https://issues.jboss.org/browse/JBTM-2756
Project: JBoss Transaction Manager
Issue Type: Bug
Components: JTS
Affects Versions: 5.3.4.Final
Reporter: Ondra Chaloupka
Static code analysis category: Nondeterministic locking behavior
_CID-17602_: Bad choice of lock object - Nondeterministic locking behavior
in class `ThreadAssociations` [1] at method `removeAll`. There is used synchronized block
where lock is acquired at `globalTxAssociations` and `txAssociations`.
The problem (one for txAssociations is described as)
lock_acquire: Acquiring lock `com.arjuna.ats.jts.extensions.`ThreadAssociations.txAssociations`.
lock_on_assigned_field: Locking on the object referenced by field `ThreadAssociations.txAssociations`. This lock acquisition may race with another thread assigning to this field. The contents of `ThreadAssociations.txAssociations` may change while a thread is inside the critical section, allowing two threads to enter the critical section simultaneously.
* Instead of using `ThreadAssociations.txAssociations` as a lock, create a final field of type Object which is only used as a lock.
assign_to_field: The expression `ThreadAssociations.txAssociations = null` assigns a new value to `ThreadAssociations.txAssociations`, a field whose contents are used as a lock. The locking behavior of this function may allow this assignment to occur multiple times.
Tom's reaction on this
{quote}
I think that the bug is that there is any synchronization at all on txAssociations because it looks to be indexed by Thread.currentThread().
{quote}
[1] https://github.com/jbosstm/narayana/blob/master/ArjunaJTS/jts/classes/com/arjuna/ats/jts/extensions/ThreadAssociations.java#L125
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jbossts-issues
mailing list