Bug 360196 - Find/Replace/Search throw Invalid Thread Access Exception
Summary: Find/Replace/Search throw Invalid Thread Access Exception
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Search (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Search-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2011-10-07 02:31 EDT by Mahesh Maney CLA
Modified: 2012-10-10 03:17 EDT (History)
2 users (show)

See Also:


Attachments
Screenshots for Find-Replace exception (346.00 KB, application/octet-stream)
2011-10-07 02:33 EDT, Mahesh Maney CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mahesh Maney CLA 2011-10-07 02:31:19 EDT
Build Identifier: 20100617-1415

We make use of Japanese version of Windows XP OS. The JDK is 1.6.0_26-b03. While trying to search some text, we always get this exception:
!ENTRY org.eclipse.ui 4 0 2011-10-03 17:52:52.695
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jface.dialogs.DialogPage.setVisible(DialogPage.java:470)
	at org.eclipse.search.internal.ui.text.TextSearchPage.setVisible(TextSearchPage.java:437)
	at org.eclipse.search.internal.ui.SearchDialog.create(SearchDialog.java:266)
	at org.eclipse.jface.window.Window.open(Window.java:790)
	at org.eclipse.search.internal.ui.OpenSearchDialogAction.run(OpenSearchDialogAction.java:54)
	at org.eclipse.search.ui.NewSearchUI.openSearchDialog(NewSearchUI.java:299)
	at org.eclipse.search.internal.ui.OpenFileSearchPageAction.run(OpenFileSearchPageAction.java:46)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
	at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)

!ENTRY org.eclipse.search 4 2 2011-10-03 17:53:12.129
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.search".
!STACK 0
org.eclipse.swt.SWTException: Invalid thread access
	at org.eclipse.swt.SWT.error(SWT.java:4083)
	at org.eclipse.swt.SWT.error(SWT.java:3998)
	at org.eclipse.swt.SWT.error(SWT.java:3969)
	at org.eclipse.swt.widgets.Display.error(Display.java:1249)
	at org.eclipse.swt.widgets.Display.checkDevice(Display.java:755)
	at org.eclipse.swt.widgets.Display.getSystemFont(Display.java:2412)
	at org.eclipse.swt.widgets.Display.internal_new_GC(Display.java:2598)
	at org.eclipse.swt.graphics.GC.<init>(GC.java:166)
	at org.eclipse.swt.graphics.GC.<init>(GC.java:132)
	at org.eclipse.jface.layout.PixelConverter.<init>(PixelConverter.java:60)
	at org.eclipse.jface.layout.PixelConverter.<init>(PixelConverter.java:49)
	at org.eclipse.search.internal.ui.util.SWTUtil.getButtonWidthHint(SWTUtil.java:85)
	at org.eclipse.search.internal.ui.text.TextSearchPage.addFileNameControls(TextSearchPage.java:681)
	at org.eclipse.search.internal.ui.text.TextSearchPage.createControl(TextSearchPage.java:465)
	at org.eclipse.search.internal.ui.SearchDialog$9.run(SearchDialog.java:666)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.search.internal.ui.SearchDialog$8.run(SearchDialog.java:661)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.search.internal.ui.SearchDialog.createPageControl(SearchDialog.java:659)
	at org.eclipse.search.internal.ui.SearchDialog.createPageArea(SearchDialog.java:401)
	at org.eclipse.search.internal.ui.util.ExtendedDialogWindow.createDialogArea(ExtendedDialogWindow.java:140)
	at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java:760)
	at org.eclipse.jface.window.Window.create(Window.java:431)
	at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
	at org.eclipse.search.internal.ui.SearchDialog.create(SearchDialog.java:264)
	at org.eclipse.jface.window.Window.open(Window.java:790)
	at org.eclipse.search.internal.ui.OpenSearchDialogAction.run(OpenSearchDialogAction.java:54)
	at org.eclipse.search.internal.ui.OpenSearchDialogAction.run(OpenSearchDialogAction.java:45)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
	at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)

Reproducible: Always

Steps to Reproduce:
1.In the editor, select any text string.
2.Do CTRL+F or select Search from the menu.
3.The exception is thrown "Find and Replace did not complete normally. Please see the log for more information. Invalid thread access.".
Comment 1 Mahesh Maney CLA 2011-10-07 02:33:23 EDT
Created attachment 204727 [details]
Screenshots for Find-Replace exception
Comment 2 Dani Megert CLA 2011-10-10 07:18:22 EDT
Something looks fishy here. It looks like some other display created the used (system) font.

Can you reproduce the problem in plain Eclipse SDK Juno:
http://download.eclipse.org/eclipse/downloads/drops4/S-4.2M2-201109161615/index.php
?
Comment 3 Dani Megert CLA 2011-10-14 06:43:19 EDT
Ping.
Comment 4 Mahesh Maney CLA 2011-10-17 03:07:26 EDT
(In reply to comment #3)
> Ping.

Sorry for the delay in looking Dani, I shall try it now and report back in few hours now.
Comment 5 Dani Megert CLA 2011-10-25 02:18:32 EDT
Works fine for me.
Comment 6 Mahesh Maney CLA 2012-02-09 00:09:46 EST
We got back the same issue couple of days back. We do a search and immediately end up in Invalid thread access exception. I have double checked for the presence of getSystemFont() anywhere in our code, but did not find any. What could be the reason this exception ? Any help/suggestion provided is much appreciated.  

org.eclipse.swt.SWTException: Invalid thread access
	at org.eclipse.swt.SWT.error(SWT.java:4282)
	at org.eclipse.swt.SWT.error(SWT.java:4197)
	at org.eclipse.swt.SWT.error(SWT.java:4168)
	at org.eclipse.swt.widgets.Display.error(Display.java:1258)
	at org.eclipse.swt.widgets.Display.checkDevice(Display.java:764)
	at org.eclipse.swt.widgets.Display.getSystemFont(Display.java:2459)
	at org.eclipse.swt.widgets.Display.internal_new_GC(Display.java:2682)
	at org.eclipse.swt.graphics.GC.<init>(GC.java:166)
	at org.eclipse.swt.graphics.GC.<init>(GC.java:132)
	at org.eclipse.jface.layout.PixelConverter.<init>(PixelConverter.java:60)
	at org.eclipse.jface.layout.PixelConverter.<init>(PixelConverter.java:49)
	at org.eclipse.ui.internal.texteditor.SWTUtil.getButtonWidthHint(SWTUtil.java:50)
	at org.eclipse.ui.internal.texteditor.SWTUtil.setButtonDimensionHint(SWTUtil.java:66)
	at org.eclipse.ui.texteditor.FindReplaceDialog.setGridData(FindReplaceDialog.java:1535)
	at org.eclipse.ui.texteditor.FindReplaceDialog.createButtonSection(FindReplaceDialog.java:329)
	at org.eclipse.ui.texteditor.FindReplaceDialog.createContents(FindReplaceDialog.java:412)
	at org.eclipse.jface.window.Window.create(Window.java:431)
	at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
	at org.eclipse.ui.texteditor.FindReplaceDialog.create(FindReplaceDialog.java:281)
	at org.eclipse.ui.texteditor.FindReplaceAction$FindReplaceDialogStub.<init>(FindReplaceAction.java:100)
	at org.eclipse.ui.texteditor.FindReplaceAction$FindReplaceDialogStub.<init>(FindReplaceAction.java:85)
	at org.eclipse.ui.texteditor.FindReplaceAction.run(FindReplaceAction.java:353)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
	at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:468)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:567)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:123)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1104)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1100)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1509)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4640)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4528)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4972)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2530)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3752)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Comment 7 Dani Megert CLA 2012-02-09 05:25:17 EST
(In reply to comment #6)
> We got back the same issue couple of days back. We do a search and immediately
> end up in Invalid thread access exception. I have double checked for the
> presence of getSystemFont() anywhere in our code, but did not find any. What
> could be the reason this exception ? Any help/suggestion provided is much
> appreciated.  

You'd have to remote debug your IDE. You can then look at why the exception is thrown and from which thread/display the other font comes. You could also set a breakpoint in org.eclipse.jface.resource.FontRegistry.put(String, FontData[], boolean) and during startup, look who creates the dialog font(s).
Comment 8 Dani Megert CLA 2012-02-09 05:40:39 EST
> You'd have to remote debug your IDE.
See:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Fconcepts%2Fcremdbug.htm
Comment 9 Mahesh Maney CLA 2012-02-29 01:37:25 EST
Danni,
I'm trying to get the infrastructure up for remote debugging. will post the detailed description of my finding here soon.
Comment 10 Mahesh Maney CLA 2012-06-15 03:56:34 EDT
Danni,
My findings;
1. The main thread was adding fonts.
2. I had set breakpoint at org.eclipse.jface.resource.FontRegistry.put(String,     
   FontData[],boolean) at the startup. All i found was the main thread was adding 
   fonts.
3. I'm not sure which/what display had issues.
4. This issue occurs very intermittently.
5. One interesting observation was, I was not able to initiate the new project 
   wizard (java project), Other than that, even if i fire the search -> File, 
   Search -> Search, Search->java , all are failing with Invalid Thread Access 
   Exception.
6. I tried the print dialog, and it poped without any errors.

During the course of Debug, i observed that in org.eclipse.swt.widgets.Display.checkDevice(), the "thread" was a Worker thread (worker-4, for Find/Replace functionality) and Thread.currentThread() was a main thread. the condition - if (thread != Thread.currentThread ()); failed resulting in Invalid Thread Access Exception.
Comment 11 Dani Megert CLA 2012-06-15 04:52:46 EDT
(In reply to comment #10)
> Danni,
> My findings;
> 1. The main thread was adding fonts.
> 2. I had set breakpoint at org.eclipse.jface.resource.FontRegistry.put(String,  
>    FontData[],boolean) at the startup. All i found was the main thread was
> adding 
>    fonts.
> 3. I'm not sure which/what display had issues.
> 4. This issue occurs very intermittently.
> 5. One interesting observation was, I was not able to initiate the new project 
>    wizard (java project), Other than that, even if i fire the search -> File, 
>    Search -> Search, Search->java , all are failing with Invalid Thread Access 
>    Exception.
> 6. I tried the print dialog, and it poped without any errors.
> 
> During the course of Debug, i observed that in
> org.eclipse.swt.widgets.Display.checkDevice(), the "thread" was a Worker thread
> (worker-4, for Find/Replace functionality) and Thread.currentThread() was a
> main thread. the condition - if (thread != Thread.currentThread ()); failed
> resulting in Invalid Thread Access Exception.

Sorry, this doesn't help. We'd need to know which thread creates that same font before, or have reproducible steps, which as I understand is not available.
Comment 12 Dani Megert CLA 2012-06-15 04:55:24 EDT
Also, please respond to comment 2.
Comment 13 Mahesh Maney CLA 2012-10-10 03:17:10 EDT
Hello Dani,

We were not able to reproduce the problem on plain Eclipse SDK Juno.