Ticket #672 (closed defect: fixed)

Opened 8 years ago

Last modified 8 years ago

Delete Axis can throw a concurrent modification exception

Reported by: bdezonia Owned by: bdezonia
Priority: major Milestone: imagej-2.0-alpha5
Component: Core Version:
Severity: serious Keywords:
Cc: Blocked By:
Blocking:

Description

Open Organ of Corti
Use Image :: Stacks :: Delete Axis plugin and delete channel axis
An exception is thrown:

Caused by: java.util.ConcurrentModificationException

at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
at java.util.HashMap$KeyIterator.next(HashMap.java:828)
at imagej.ui.swing.display.SwingDisplayWindow.createSliders(SwingDisplayWindow.java:325)
at imagej.ui.swing.display.SwingDisplayWindow.access$2(SwingDisplayWindow.java:280)
at imagej.ui.swing.display.SwingDisplayWindow$2.onEvent(SwingDisplayWindow.java:208)
at imagej.ui.swing.display.SwingDisplayWindow$2.onEvent(SwingDisplayWindow.java:1)
at org.bushe.swing.event.ThreadSafeEventService.publish(ThreadSafeEventService.java:971)

Change History

comment:1 Changed 8 years ago by bdezonia

  • Milestone changed from biweekly-2011: Jul-18 to Jul-29 to biweekly-2011: Aug-01 to Aug-12

comment:2 Changed 8 years ago by bdezonia

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from biweekly-2011: Aug-01 to Aug-12 to biweekly-2011: Jul-18 to Jul-29

Fixed in 9baf85e833863fbbf8573ead3ae91803d77c330c

Had to disable some event handling code
Left explanation and original code commented out for easy restoration if necessary

comment:3 Changed 8 years ago by bdezonia

  • Status changed from closed to reopened
  • Resolution fixed deleted

Still an issue:

Organ of Corti
Delete Data: Z axis, pos 4, num slice 6
Delete Axis: Channel axis, keep position 1

Exception below:

Note that because of exception channel slider does not go away. If you increment Z the sliders fix up.

This problem has to do with multiple people tracking DatasetRestructured and eventually calling redo layout() at the same time (where it dies in createSliders()).

Must find the minimal tracking of restructuring or redolayout()ing. Or make createSliders() synchronized.

Caused by: java.util.ConcurrentModificationException

at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
at java.util.HashMap$KeyIterator.next(HashMap.java:828)
at imagej.ui.swing.display.SwingDisplayWindow.createSliders(SwingDisplayWindow.java:333)
at imagej.ui.swing.display.SwingDisplayWindow.redoLayout(SwingDisplayWindow.java:163)
at imagej.ui.swing.display.SwingImageDisplay.update(SwingImageDisplay.java:169)
at imagej.display.AbstractDisplayView$2.onEvent(AbstractDisplayView.java:176)
at imagej.display.AbstractDisplayView$2.onEvent(AbstractDisplayView.java:1)
at org.bushe.swing.event.ThreadSafeEventService.publish(ThreadSafeEventService.java:971)

comment:4 Changed 8 years ago by bdezonia

  • Milestone changed from biweekly-2011: Jul-18 to Jul-29 to imagej-2.0-alpha5

comment:5 Changed 8 years ago by bdezonia

Curtis is committing some code in the Swing dependent classes that utilizes SwingUtilities.invokeLater(). He will commit soon. It did not remove all errors though. The above scenario still failed 90% of the time. Wating for Curtis to commit after alpha 4 release and will retest then.

comment:6 Changed 8 years ago by bdezonia

Harder to recreate now. But am able to with this sequence:

Open Mitosis
Delete Axis, Channel, 1

Exception:

Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException

at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
at java.util.HashMap$KeyIterator.next(HashMap.java:828)
at imagej.ui.swing.display.SwingDisplayWindow.createSliders(SwingDisplayWindow.java:340)
at imagej.ui.swing.display.SwingDisplayWindow.access$1(SwingDisplayWindow.java:294)
at imagej.ui.swing.display.SwingDisplayWindow$1.run(SwingDisplayWindow.java:168)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:638)
at java.awt.EventQueue$1.run(EventQueue.java:636)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:647)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

comment:7 Changed 8 years ago by bdezonia

Cannot find issue yet. It is failing trying to get the keySet() of the axisSliders Map. axisSliders is a private variable with no public accessors. There is an axis position event handler that can use axisSliders but by debugging I've determined it never gets called.

Otherwise the axisSliders Map is only accessed by createSliders(). By debugging and also using print statements I can determine that createSliders() is only getting called once (!!!??). So can't see how concurrency is an issue.

Making createSliders() synchronized no longer fixes the issue either.

comment:8 Changed 8 years ago by bdezonia

  • Summary changed from Delete Axis can throw a concurrent mofication exception to Delete Axis can throw a concurrent modification exception

comment:9 Changed 8 years ago by bdezonia

  • Status changed from reopened to closed
  • Resolution set to fixed

Making the axisSliders instance variable a ConcurrentHashMap rather than a regular HashMap fixes the problem. This is a hack which I've documented in the file and referenced this bug number.

The sequence that fails if regular HashMap but works if ConcurrentHashMap:

Open Mitosis
Delete Axis (Channel axis, keep hyperplane 1)

comment:10 Changed 8 years ago by bdezonia

Forgot to mention revision of fix: 7a361035fac48264c6ff37c75f44cfe282717f1f

comment:11 Changed 8 years ago by bdezonia

  • Status changed from closed to reopened
  • Resolution fixed deleted

As a result of the recent display refactoring this bug has been resurrected. I have noted where the missing code is (axis sliders declaration needs to be ConcurrentHashMap) and have queried Grant as to whether any more code is missing.

comment:12 Changed 8 years ago by bdezonia

  • Status changed from reopened to closed
  • Resolution set to fixed

refixed with cec28bc4630ec860ca5923887f975a5ccc0ce53d

Note: See TracTickets for help on using tickets.