Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock in UI #42

Closed
BenjaminBeichler opened this issue Jun 28, 2019 · 5 comments
Closed

Deadlock in UI #42

BenjaminBeichler opened this issue Jun 28, 2019 · 5 comments

Comments

@BenjaminBeichler
Copy link
Contributor

I have the problem, that when I'm debugging programs with single stepping, often the UI freezes. I use oracle Java 8 on Windows 10 with 64 bit.

The problem seems to be, that when a jump occures and the text segment window needs to be updated, it fairly often happens. An example program is:

.text
	jal L2
loop:	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	jal loop
L2:	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1	
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
L1:	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	addi t0,t0,1
	
	bne t0,zero,loop

Sorry, maybe it could be smaller, it is important, that the text segment window need to scroll.
To trigger the problem you need to single step through the program. It runs fine with normal execution.

I have no full java develpoment environment available, but I connected jvisualvm, an got the following output of a thread dump:

Found one Java-level deadlock:
=============================
"RISCV":
  waiting to lock monitor 0x000000001f628458 (object 0x00000006c28ef1f0, a java.awt.Component$AWTTreeLock),
  which is held by "AWT-EventQueue-0"
"AWT-EventQueue-0":
  waiting to lock monitor 0x000000001f6283a8 (object 0x00000006c3711778, a javax.swing.plaf.metal.MetalCheckBoxUI),
  which is held by "RISCV"

Java stack information for the threads listed above:
===================================================
"RISCV":
        at javax.swing.plaf.metal.MetalUtils$GradientPainter.paint(Unknown Source)
        - waiting to lock <0x00000006c28ef1f0> (a java.awt.Component$AWTTreeLock)
        at javax.swing.plaf.metal.MetalUtils.drawGradient(Unknown Source)
        at javax.swing.plaf.metal.MetalIconFactory$CheckBoxIcon.paintOceanIcon(Unknown Source)
        at javax.swing.plaf.metal.MetalIconFactory$CheckBoxIcon.paintIcon(Unknown Source)
        at javax.swing.plaf.metal.MetalRadioButtonUI.paint(Unknown Source)
        - locked <0x00000006c3711778> (a javax.swing.plaf.metal.MetalCheckBoxUI)
        at javax.swing.plaf.ComponentUI.update(Unknown Source)
        at javax.swing.JComponent.paintComponent(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.CellRendererPane.paintComponent(Unknown Source)
        at javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source)
        at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source)
        at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source)
        at javax.swing.plaf.ComponentUI.update(Unknown Source)
        at javax.swing.JComponent.paintComponent(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintToOffscreen(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
        at javax.swing.RepaintManager.paint(Unknown Source)
        at javax.swing.JComponent.paintForceDoubleBuffered(Unknown Source)
        at javax.swing.JViewport.paintView(Unknown Source)
        at javax.swing.JViewport.windowBlitPaint(Unknown Source)
        at javax.swing.JViewport.setViewPosition(Unknown Source)
        at javax.swing.JViewport.scrollRectToVisible(Unknown Source)
        at javax.swing.JComponent.scrollRectToVisible(Unknown Source)
        at rars.venus.TextSegmentWindow.highlightStepAtAddress(TextSegmentWindow.java:508)
        at rars.venus.TextSegmentWindow.highlightStepAtPC(TextSegmentWindow.java:488)
        at rars.venus.run.RunStepAction.stepped(RunStepAction.java:104)
        at rars.venus.run.RunStepAction$1.update(RunStepAction.java:83)
        at java.util.Observable.notifyObservers(Unknown Source)
        at rars.simulator.Simulator.notifyObserversOfExecution(Simulator.java:184)
        at rars.simulator.Simulator.access$500(Simulator.java:51)
        at rars.simulator.Simulator$SimThread.stopExecution(Simulator.java:244)
        at rars.simulator.Simulator$SimThread.run(Simulator.java:441)
        - locked <0x00000006c28116a8> (a java.lang.Object)
        at java.lang.Thread.run(Unknown Source)
"AWT-EventQueue-0":
        at javax.swing.plaf.metal.MetalRadioButtonUI.paint(Unknown Source)
        - waiting to lock <0x00000006c3711778> (a javax.swing.plaf.metal.MetalCheckBoxUI)
        at javax.swing.plaf.ComponentUI.update(Unknown Source)
        at javax.swing.JComponent.paintComponent(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.CellRendererPane.paintComponent(Unknown Source)
        at javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source)
        at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source)
        at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source)
        at javax.swing.plaf.ComponentUI.update(Unknown Source)
        at javax.swing.JComponent.paintComponent(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        - locked <0x00000006c28ef1f0> (a java.awt.Component$AWTTreeLock)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JViewport.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        - locked <0x00000006c28ef1f0> (a java.awt.Component$AWTTreeLock)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintToOffscreen(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
        at javax.swing.RepaintManager.paint(Unknown Source)
        at javax.swing.JComponent._paintImmediately(Unknown Source)
        at javax.swing.JComponent.paintImmediately(Unknown Source)
        at javax.swing.RepaintManager$4.run(Unknown Source)
        at javax.swing.RepaintManager$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.access$1200(Unknown Source)
        at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

Found 1 deadlock.

Hopefully, you can fix this. If you need further information, let me know.

@TheThirdOne
Copy link
Owner

Thanks for the report. I can reproduce this, but it may take some time to debug it.

It looks like this might be caused by updating UI elements from the RISCV thread through the observer interface. It should be fixable by making the observers schedule a UI update rather than doing it.

TheThirdOne added a commit that referenced this issue Jun 28, 2019
As predicted this came from updating UI on the RISCV thread and was
solved by using EventQueue.invokeLater

Likely other buttons have similar issues so I will need to go through
and make sure they also are fixed.
@TheThirdOne
Copy link
Owner

This should be fixed now. Would you please confirm?

I'll still need to check other areas to see prevent any other similar problems so I'll leave this open until I check on them.

@TheThirdOne
Copy link
Owner

So there indeed was a similar problem with the run button. If you set up your program with every line breakpointed and then hit run a bunch it will end up throwing a null-pointer exception.

I fixed that in 6afb286, so I'll close this once you confirm the problem is fixed for you.

@BenjaminBeichler
Copy link
Contributor Author

Sorry for my late response.

All my programs run while stepping fine, so it seems to be fixed.

Thanks!

@TheThirdOne
Copy link
Owner

Great. Thanks for helping squash this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants