Bug 475660 - Data race on org.eclipse.swt.widgets.Display.wake
Summary: Data race on org.eclipse.swt.widgets.Display.wake
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2015-08-23 04:33 EDT by Yilong Li CLA
Modified: 2018-12-07 11:23 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yilong Li CLA 2015-08-23 04:33:47 EDT
Here is the race report given by a dynamic race detector:
Data race on field org.eclipse.swt.widgets.Display.wake: {{{
    Concurrent write in thread T1 (locks held: {})
 ---->  at org.eclipse.swt.widgets.Display.sleep(Display.java:4319)
        at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Display.test_getSyncThread(Test_org_eclipse_swt_widgets_Display.java:428)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runners.Suite.runChild(Suite.java:128)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:38)
        at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:692)
        at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:319)
        at org.eclipse.test.CoreTestApplication.runTests(CoreTestApplication.java:36)
        at org.eclipse.test.CoreTestApplication.run(CoreTestApplication.java:32)
        at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
        at org.eclipse.core.launcher.Main.main(Main.java:34)
    T1 is the main thread

    Concurrent write in thread T29 (locks held: {Monitor@533a48e1})
 ---->  at org.eclipse.swt.widgets.Display.wakeThread(Display.java:4694)
        at org.eclipse.swt.widgets.Synchronizer.addLast(Synchronizer.java:70)
        at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:179)
        - locked Monitor@533a48e1 at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:167) 
        at org.eclipse.swt.widgets.Display.syncExec(Display.java:4633)
        at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Display$6.run(Test_org_eclipse_swt_widgets_Display.java:399)
    T29 is created by T1
        at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Display.test_getSyncThread(Test_org_eclipse_swt_widgets_Display.java:425)
}}}

I have seen this race in other scenarios such as https://bugs.eclipse.org/bugs/show_bug.cgi?id=475145 & https://bugs.eclipse.org/bugs/show_bug.cgi?id=475168. I wasn't sure whether this class, org.eclipse.swt.widgets.Display, was supposed to be thread-safe so I only reported the race to Platform/UI and JDT teams. This time I am running SWT's own test suite so it's clear that the problem is in org.eclipse.swt.widgets.Display. 

Perhaps Display.wake should be declared as volatile?
Comment 1 Xi Yan CLA 2018-08-16 16:59:43 EDT
Can you provide the steps to reproduce the issue?
Comment 2 Xi Yan CLA 2018-12-07 11:23:00 EST
No response for months, closing. Please reopen the ticket with more info if the issue reoccurs.