Project: SWT
Bug 215252 frequent "invalid thread access"
Reported: 2008-01-14 14:57:06 | Status: resolved fixed

I'm not sure 100% where the problem lies with this (hard to say if it's SWT, or JFace, or what), but since updgrading to 3.4 M4 I've been having invalid thread accesses like crazy. This also coincided with getting a new dual core laptop, which is much more likely the issue. I don't necessarily have to be doing anything for these errors to happen. Just leaving the workbench sitting long enough with some editors open is usually enough. Unfortunately all I have are some stack traces from the error log, I have yet to find a reproducible test case other than "just wait, it will happen". Once the error happens, UI behaviour of the workbench gets very flaky... text entry starts showing up in reverse in text controls for example. The text entry problem seems to be the most common symptom so far. Some example stack traces are below. Apologies in advance if this is a dupe. I searched for bugs related to "invalid thread access" and there were 200+ of them, which was too many to wade through. If there is any way I can be of better aid in narrowing this down, let me know. eclipse.buildId=I20071213-1700 java.fullversion=J2RE 1.6.0 IBM J9 2.4 Windows XP x86-32 jvmwi3260-20071121_15015 (JIT enabled) J9VM - 20071121_015015_lHdSMR JIT - r9_20071121_1330 GC - 20071031_AA BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86 Error Mon Jan 14 12:07:24 EST 2008 Unhandled event loop exception org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3716) at org.eclipse.swt.SWT.error(SWT.java:3634) at org.eclipse.swt.SWT.error(SWT.java:3605) at org.eclipse.swt.widgets.Widget.error(Widget.java:441) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:335) at org.eclipse.swt.custom.StyledText.getBackground(StyledText.java:3054) at org.eclipse.swt.custom.StyledText.handlePaint(StyledText.java:5291) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4866) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:976) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:961) at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1402) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3831) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:334) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4450) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2329) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3359) at org.eclipse.jface.window.Window.runEventLoop(Window.java:825) at org.eclipse.jface.window.Window.open(Window.java:801) at org.eclipse.ui.internal.views.log.EventDetailsDialog.open(EventDetailsDialog.java:166) at org.eclipse.ui.internal.views.log.EventDetailsDialogAction.run(EventDetailsDialogAction.java:90) at org.eclipse.ui.internal.views.log.LogView$15.doubleClick(LogView.java:573) at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:799) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.runtime.Platform.run(Platform.java:857) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:46) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:199) at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:797) at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1416) at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1173) at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:237) at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:234) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:295) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3750) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3361) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2381) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2345) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2211) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:473) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:468) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:362) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:612) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:561) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:501) at org.eclipse.equinox.launcher.Main.run(Main.java:1239) at org.eclipse.equinox.launcher.Main.main(Main.java:1215) eclipse.buildId=I20071213-1700 java.fullversion=J2RE 1.6.0 IBM J9 2.4 Windows XP x86-32 jvmwi3260-20071121_15015 (JIT enabled) J9VM - 20071121_015015_lHdSMR JIT - r9_20071121_1330 GC - 20071031_AA BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86 This is a continuation of log file C:\cdt_head_workspace\.metadata\.bak_0.log Created Time: 2008-01-14 11:23:42.562 Error Mon Jan 14 11:24:47 EST 2008 Unhandled event loop exception org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3716) at org.eclipse.swt.SWT.error(SWT.java:3634) at org.eclipse.swt.SWT.error(SWT.java:3605) at org.eclipse.swt.widgets.Widget.error(Widget.java:441) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:335) at org.eclipse.swt.custom.StyledText.replaceStyleRanges(StyledText.java:6342) at org.eclipse.jface.text.TextViewer.addPresentation(TextViewer.java:4432) at org.eclipse.jface.text.TextViewer.changeTextPresentation(TextViewer.java:4511) at org.eclipse.jface.text.presentation.PresentationReconciler.applyTextRegionCollection(PresentationReconciler.java:580) at org.eclipse.jface.text.presentation.PresentationReconciler.processDamage(PresentationReconciler.java:569) at org.eclipse.jface.text.presentation.PresentationReconciler.access$3(PresentationReconciler.java:565) at org.eclipse.jface.text.presentation.PresentationReconciler$InternalListener.textChanged(PresentationReconciler.java:225) at org.eclipse.jface.text.TextViewer.updateTextListeners(TextViewer.java:2637) at org.eclipse.jface.text.TextViewer$VisibleDocumentListener.documentChanged(TextViewer.java:373) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged2(AbstractDocument.java:700) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:673) at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:658) at org.eclipse.jface.text.AbstractDocument.fireDocumentChanged(AbstractDocument.java:723) at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1081) at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1099) at org.eclipse.jface.text.DefaultDocumentAdapter.replaceTextRange(DefaultDocumentAdapter.java:248) at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:5861) at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:6600) at org.eclipse.swt.custom.StyledText.doDelete(StyledText.java:2264) at org.eclipse.swt.custom.StyledText.invokeAction(StyledText.java:5752) at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5136) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5157) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4861) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:976) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:961) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:989) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:985) at org.eclipse.swt.widgets.Widget.wmKeyDown(Widget.java:1587) at org.eclipse.swt.widgets.Control.WM_KEYDOWN(Control.java:4111) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3807) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:334) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4463) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2329) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3359) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2381) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2345) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2211) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:473) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:468) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:362) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:612) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:561) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:501) at org.eclipse.equinox.launcher.Main.run(Main.java:1239) at org.eclipse.equinox.launcher.Main.main(Main.java:1215) eclipse.buildId=I20071213-1700 java.fullversion=J2RE 1.6.0 IBM J9 2.4 Windows XP x86-32 jvmwi3260-20071121_15015 (JIT enabled) J9VM - 20071121_015015_lHdSMR JIT - r9_20071121_1330 GC - 20071031_AA BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86 This is a continuation of log file C:\cdt_head_workspace\.metadata\.bak_0.log Created Time: 2008-01-14 11:23:42.562 Error Mon Jan 14 11:24:18 EST 2008 Unhandled event loop exception org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Invalid thread access) at org.eclipse.swt.SWT.error(SWT.java:3716) at org.eclipse.swt.SWT.error(SWT.java:3634) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3727) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3364) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2381) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2345) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2211) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:473) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:468) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:362) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:612) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:561) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:501) at org.eclipse.equinox.launcher.Main.run(Main.java:1239) at org.eclipse.equinox.launcher.Main.main(Main.java:1215) Caused by: org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3716) at org.eclipse.swt.SWT.error(SWT.java:3634) at org.eclipse.swt.SWT.error(SWT.java:3605) at org.eclipse.swt.widgets.Widget.error(Widget.java:441) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:335) at org.eclipse.swt.custom.StyledText.replaceStyleRanges(StyledText.java:6342) at org.eclipse.jface.text.TextViewer.addPresentation(TextViewer.java:4432) at org.eclipse.jface.text.TextViewer.changeTextPresentation(TextViewer.java:4511) at org.eclipse.jface.text.presentation.PresentationReconciler.applyTextRegionCollection(PresentationReconciler.java:580) at org.eclipse.jface.text.presentation.PresentationReconciler.processDamage(PresentationReconciler.java:569) at org.eclipse.jface.text.presentation.PresentationReconciler.access$3(PresentationReconciler.java:565) at org.eclipse.jface.text.presentation.PresentationReconciler$InternalListener.textChanged(PresentationReconciler.java:225) at org.eclipse.jface.text.TextViewer.updateTextListeners(TextViewer.java:2637) at org.eclipse.jface.text.TextViewer.invalidateTextPresentation(TextViewer.java:3284) at org.eclipse.jface.text.source.AnnotationPainter.invalidateTextPresentation(AnnotationPainter.java:959) at org.eclipse.jface.text.source.AnnotationPainter.updatePainting(AnnotationPainter.java:941) at org.eclipse.jface.text.source.AnnotationPainter.access$1(AnnotationPainter.java:935) at org.eclipse.jface.text.source.AnnotationPainter$1.run(AnnotationPainter.java:1074) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:130) ... 23 more

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java