GNOME Bugzilla – Bug 766774
Avoid calling getAccessibleContext from the loop thread
Last modified: 2019-05-01 22:06:38 UTC
Hello, We have seen threading issues in josm, because getCurrentAccessibleContext ends up being called frop the loop thread, which leads to an unexpected call to application methods from the loop thread, for which the application does not implement synchronization, since normally there is no concurrency there. For instance: java.lang.NullPointerException at org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionTypeCalculator.Fixthread(WayConnectionTypeCalculator.java:36) at org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionTypeCalculator.updateLinks(WayConnectionTypeCalculator.java:43) at org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel.getWayConnection(MemberTableModel.java:761) at org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel.getValueAt(MemberTableModel.java:219) at javax.swing.JTable.getValueAt(JTable.java:2717) at javax.swing.JTable$AccessibleJTable$AccessibleJTableCell.getCurrentAccessibleContext(JTable.java:7950) at javax.swing.JTable$AccessibleJTable$AccessibleJTableCell.addPropertyChangeListener(JTable.java:8189) at org.GNOME.Accessibility.AtkWrapper.registerPropertyChangeListener(AtkWrapper.java:625) Here, getValueAt was overloaded by the application, and thus the mere call to getCurrentAccessibleContext ended up expectedly calling application code. In the proposed patch, we call jaw_impl_get_instance from the java accessibility callback, instead of delaying that to the callback in the atk glib loop. This however brings concurrent access to the object hash table. This can be simply protected by a mutex, as shown in the other submitted patch. Samuel
Created attachment 328347 [details] [review] Add a mutex for the object hash table
Created attachment 328348 [details] [review] Avoid unexpected threaded call to application callbacks
Created attachment 368479 [details] [review] Avoid unexpected threaded call to application callbacks Here is an updated version, with proper printfs.
Fixed by e7588805b89552a6154356cc013927484f7bf0b6 ("Call jaw_impl_get_instance from the application thread")