Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [rap-dev] Display.findDisplay is deadlock prone

Hi,

Thank you for the analysis and the PR. We will look at it as soon as possible after RAP 4.4 release.

Best regards,
Ivan


On Thu, Sep 4, 2025 at 5:09 PM 41zu <dominikator.mueka@xxxxxxxxxxxxxx> wrote:
I updated the code. Tests are passing and tested it in my product, plus analyzed it with VisualVM. 
For it to test it in my product, I only replaced the org.eclipse.rap.rwt plugin with my own compiled one.

In my testing I noticed, that the UILockListener can keep an reference to the display object (see Screenshot), which holds the reference to the thread, that's why the entry in the WeakHashMap is not removed. But because the display is already disposed, the findDisplay method would not return it. Didn't look, why the UILockListener keeps an reference, just wanted to mention that. The UILockListener would let the reference go, when a new session is created, then the entry will be removed.

Best regards,
Dominik



Am Di., 2. Sept. 2025 um 20:02 Uhr schrieb 41zu <dominikator.mueka@xxxxxxxxxxxxxx>:
That wouldn't work, because findDisplay is a static method. I created a draft pull request [1]. What do you think of that solution? Sadly I cannot test it, because I don't know how to use the locally build plugins in my product.


Am Di., 2. Sept. 2025 um 14:18 Uhr schrieb Ivan Furnadjiev <ivan@xxxxxxxxxxxxxxxxx>:
Hi,

Thank you for reporting the issue. I looked at the code and it seems that in the Display class we have some old SWT synchronization based on Device.class. Could you please replace the "synchronized( Device.class )" in Display methods "findDisplay", "register" and "deregister" with "synchronized( deviceLock )". Please report if this change fixes the problem.

Best regards,
Ivan


On Tue, Sep 2, 2025 at 2:48 PM 41zu via rap-dev <rap-dev@xxxxxxxxxxx> wrote:
Hello dear RAP devs,

I had a deadlock in my RAP application and I think I found the culprit. Please tell me if I'm wrong in my assessment.

The current implementation of findDisplay (as of 4.3) loops trough the displays and checks if they are disposed. The problem is, that in the findDisplay method the Device-Class-Lock is taken and in the isDisposed method, the deviceLock gets locked, which may already be locked. In this example by Device::dispose. which also now wants the Device-Class-Lock, which is already taken in findDisplay.

The deadlock was found by VisualVM. The deadlock information is below.

Best regards,
Dominik

DEADLOCK INFORMATION:
Found one Java-level deadlock:
=============================
"UIThread [17ed3d14]":
  waiting to lock monitor 0x00000236031ae330 (object 0x0000000606453418, a java.lang.Class),
  which is held by "UIThread [37fe6e1b]"

"UIThread [37fe6e1b]":
  waiting to lock monitor 0x000002360336e970 (object 0x0000000617e3dd38, a org.eclipse.rap.rwt.internal.util.SerializableLock),
  which is held by "UIThread [17ed3d14]"

Java stack information for the threads listed above:
===================================================
"UIThread [17ed3d14]":
        at org.eclipse.swt.widgets.Display.deregister(Display.java:2255)
        - waiting to lock <0x0000000606453418> (a java.lang.Class for org.eclipse.swt.graphics.Device)
        at org.eclipse.swt.widgets.Display.destroy(Display.java:751)
        at org.eclipse.swt.graphics.Device.dispose(Device.java:280)
        - locked <0x0000000617e3dd38> (a org.eclipse.rap.rwt.internal.util.SerializableLock)
        at com.orthagis.rcp.main.Main.start(Main.java:115)
        at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
        at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:177)
        at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:290)
        - locked <0x0000000607d750c8> (a org.eclipse.rap.rwt.internal.lifecycle.UIThread)
        at java.lang.Thread.runWith(java.base@21.0.7/Thread.java:1596)
        at java.lang.Thread.run(java.base@21.0.7/Thread.java:1583)
        at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:107)
"UIThread [37fe6e1b]":
        at org.eclipse.swt.graphics.Device.isDisposed(Device.java:297)
        - waiting to lock <0x0000000617e3dd38> (a org.eclipse.rap.rwt.internal.util.SerializableLock)
        at org.eclipse.swt.widgets.Display.findDisplay(Display.java:946)
        - locked <0x0000000606453418> (a java.lang.Class for org.eclipse.swt.graphics.Device)
        at com.orthagis.rcp.main.RcpActionBarAdvisor.getMailActionForThread(RcpActionBarAdvisor.java:408)
        at com.orthagis.rcp.editor.EntityEditorActionContributor.dispose(EntityEditorActionContributor.java:206)
        at org.eclipse.ui.internal.EditorActionBars.dispose(EditorActionBars.java:156)
        at org.eclipse.ui.internal.EditorManager.disposeEditorActionBars(EditorManager.java:362)
        at org.eclipse.ui.internal.EditorReference.doDisposePart(EditorReference.java:327)
        at org.eclipse.ui.internal.WorkbenchPartReference.dispose(WorkbenchPartReference.java:688)
        at org.eclipse.ui.internal.WorkbenchPage.disposePart(WorkbenchPage.java:1719)
        at org.eclipse.ui.internal.WorkbenchPage.handleDeferredEvents(WorkbenchPage.java:1424)
        at org.eclipse.ui.internal.WorkbenchPage.deferUpdates(WorkbenchPage.java:1408)
        at org.eclipse.ui.internal.WorkbenchPage.closeEditors(WorkbenchPage.java:1382)
        at org.eclipse.ui.internal.WorkbenchPage.closeAllEditors(WorkbenchPage.java:1190)
        at org.eclipse.ui.internal.WorkbenchPage.dispose(WorkbenchPage.java:1769)
        at org.eclipse.ui.internal.WorkbenchWindow.closeAllPages(WorkbenchWindow.java:853)
        at org.eclipse.ui.internal.WorkbenchWindow.hardClose(WorkbenchWindow.java:1779)
        at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:726)
        at org.eclipse.ui.internal.WorkbenchWindow$5.run(WorkbenchWindow.java:818)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66)
        at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:816)
        at org.eclipse.jface.window.WindowManager.close(WindowManager.java:110)
        at org.eclipse.ui.internal.Workbench$14.run(Workbench.java:1151)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
        at org.eclipse.ui.internal.Workbench.busyClose(Workbench.java:1148)
        at org.eclipse.ui.internal.Workbench$21.run(Workbench.java:1337)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66)
        at org.eclipse.ui.internal.Workbench.close(Workbench.java:1335)
        at org.eclipse.ui.internal.Workbench.close(Workbench.java:1297)
        at org.eclipse.ui.internal.Workbench$ShutdownHandler.handleEvent(Workbench.java:387)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:109)
        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:664)
        at org.eclipse.swt.widgets.Display.sendDisposeEvent(Display.java:755)
        at org.eclipse.swt.widgets.Display.release(Display.java:738)
        at org.eclipse.swt.graphics.Device.dispose(Device.java:279)
        - locked <0x0000000625013178> (a org.eclipse.rap.rwt.internal.util.SerializableLock)
        at com.orthagis.rcp.main.Main.start(Main.java:115)
        at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
        at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:177)
        at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:290)
        - locked <0x00000006250120b8> (a org.eclipse.rap.rwt.internal.lifecycle.UIThread)
        at java.lang.Thread.runWith(java.base@21.0.7/Thread.java:1596)
        at java.lang.Thread.run(java.base@21.0.7/Thread.java:1583)
        at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:107)

_______________________________________________
rap-dev mailing list
rap-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/rap-dev

Back to the top