Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Deadlock in my editor during 3.3.1 startup
Deadlock in my editor during 3.3.1 startup [message #322319] Tue, 13 November 2007 21:13 Go to next message
Farokh Morshed is currently offline Farokh MorshedFriend
Messages: 53
Registered: July 2009
Member
I have been using 3.2.2 and just installed 3.3.1 and tried out our plugin.
Our plugin has an editor. With 3.3.1 it deadlocks during startup. I
think it is because I call ProgressManager's runWithBusyCursor in the
editor's createSourceViewer and when runWithBusyCursor starts a new thread
to do what I told it to do, and before it gets to my code, it does a
Display.syncExec. This method makes runnables wait until "isStarting" is
false.

What's going on here? Am I not supposed to call runWithBusyCursor in my
editor because it could be called during startup?

Here's the stack frames:



org.eclipse.equinox.launcher.Main at localhost:1323
Thread [main] (Suspended)
OS.WaitMessage() line: not available [native method]
Display.sleep() line: 4070
ModalContext$ModalContextThread.block() line: 159
ModalContext.run(IRunnableWithProgress, boolean, IProgressMonitor,
Display) line: 326
ProgressMonitorJobsDialog(ProgressMonitorDialog).run(boolean , boolean,
IRunnableWithProgress) line: 495
ProgressMonitorJobsDialog.run(boolean, boolean, IRunnableWithProgress)
line: 268
ProgressManager$3.run() line: 909
BusyIndicator.showWhile(Display, Runnable) line: 67
ProgressManager.busyCursorWhile(Runnable, ProgressMonitorJobsDialog)
line: 944
ProgressManager.busyCursorWhile(IRunnableWithProgress) line: 919
ProxyRunnables.runWithBusyCursor(IRunnableWithProgress) line: 83
SourceViewProxy.createSourceView(IWorkbenchPartSite, String, Composite,
IProgressMonitor) line: 67
CurlEditor.establishViewProxy() line: 404
CurlEditor.createSourceViewer(Composite, IVerticalRuler, int) line: 344
CurlEditor(AbstractTextEditor).createPartControl(Composite) line: 3197
CurlEditor(StatusTextEditor).createPartControl(Composite) line: 53
CurlEditor(AbstractDecoratedTextEditor).createPartControl(Co mposite)
line: 378
EditorReference.createPartHelper() line: 661
EditorReference.createPart() line: 426
EditorReference(WorkbenchPartReference).getPart(boolean) line: 592
EditorAreaHelper.setVisibleEditor(IEditorReference, boolean) line: 263
EditorManager.setVisibleEditor(IEditorReference, boolean) line: 1405
EditorManager$5.runWithException() line: 939
EditorManager$5(StartupThreading$StartupRunnable).run() line: 31
RunnableLock.run() line: 35
UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 123
Display.runAsyncMessages(boolean) line: 3659
Display.readAndDispatch() line: 3296
IDEWorkbenchAdvisor(WorkbenchAdvisor).openWindows() line: 801
Workbench$25.runWithException() line: 1342
Workbench$25(StartupThreading$StartupRunnable).run() line: 31
RunnableLock.run() line: 35
UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 123
Display.runAsyncMessages(boolean) line: 3659
Display.readAndDispatch() line: 3296
Workbench.runUI() line: 2309
Workbench.access$4(Workbench) line: 2219
Workbench$4.run() line: 466
Realm.runWithDefault(Realm, Runnable) line: 289
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 461
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149
IDEApplication.start(IApplicationContext) line: 106
EclipseAppHandle.run(Object) line: 169
EclipseAppLauncher.runApplication(Object) line: 106
EclipseAppLauncher.start(Object) line: 76
EclipseStarter.run(Object) line: 363
EclipseStarter.run(String[], Runnable) line: 176
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
Main.invokeFramework(String[], URL[]) line: 508
Main.basicRun(String[]) line: 447
Main.run(String[]) line: 1173
Main.main(String[]) line: 1148
Daemon Thread [State Data Manager] (Running)
Daemon Thread [Framework Event Dispatcher] (Running)
Daemon Thread [Start Level Event Dispatcher] (Running)
Thread [Worker-0] (Suspended)
Object.wait(long) line: not available [native method]
WorkerPool.sleep(long) line: 185
WorkerPool.startJob(Worker) line: 217
Worker.run() line: 51
Thread [Thread-1] (Suspended)
Object.wait(long) line: not available [native method]
RunnableLock(Object).wait() line: 474
UISynchronizer(Synchronizer).syncExec(Runnable) line: 169
UISynchronizer.syncExec(Runnable) line: 118
Display.syncExec(Runnable) line: 4097
StartupThreading.runWithoutExceptions(StartupThreading$Start upRunnable)
line: 94
Workbench.init() line: 1337
Workbench.access$34(Workbench) line: 1274
Workbench$57.run() line: 2301
Thread [Thread-2] (Suspended)
Object.wait(long) line: not available [native method]
RunnableLock(Object).wait() line: 474
UISynchronizer(Synchronizer).syncExec(Runnable) line: 169
UISynchronizer.syncExec(Runnable) line: 118
Display.syncExec(Runnable) line: 4097
StartupThreading.runWithThrowable(StartupThreading$StartupRu nnable)
line: 85
EditorManager.restoreState(IMemento) line: 933
WorkbenchPage.restoreState(IMemento, IPerspectiveDescriptor) line: 3043
WorkbenchWindow.restoreState(IMemento, IPerspectiveDescriptor) line:
2071
Workbench.doRestoreState(IMemento, MultiStatus) line: 3352
Workbench.access$32(Workbench, IMemento, MultiStatus) line: 3294
Workbench$53.run() line: 2112
Workbench.runStartupWithProgress(int, Runnable) line: 1820
Workbench.restoreState(IMemento) line: 2110
Workbench.access$30(Workbench, IMemento) line: 2081
Workbench$48.run() line: 1939
SafeRunner.run(ISafeRunnable) line: 37
Workbench.restoreState() line: 1883
WorkbenchConfigurer.restoreState() line: 183
WorkbenchAdvisor$1.run() line: 779
Thread [Curl Eclipse Server] (Running)
Thread [ModalContext] (Suspended)
Object.wait(long) line: not available [native method]
UISynchronizer(Object).wait() line: 474
UISynchronizer.syncExec(Runnable) line: 108
Display.syncExec(Runnable) line: 4097
ModalContext$ModalContextThread.run() line: 134
Re: Deadlock in my editor during 3.3.1 startup [message #322345 is a reply to message #322319] Wed, 14 November 2007 13:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Farokh,

So I get the impression that the editor is being restored as you start
running, i.e., this thread is waiting for the GUI thread to create the
editor:

Object.wait(long) line: not available [native method]
RunnableLock(Object).wait() line: 474
UISynchronizer(Synchronizer).syncExec(Runnable) line: 169
UISynchronizer.syncExec(Runnable) line: 118
Display.syncExec(Runnable) line: 4097

StartupThreading.runWithThrowable(StartupThreading$StartupRu nnable)
line: 85
EditorManager.restoreState(IMemento) line: 933

Then the GUI thread is ending up waiting. I guess it's waiting for Jobs
to complete, but of course that will never happen because there is a job
waiting for this editor to complete.

OS.WaitMessage() line: not available [native method]
Display.sleep() line: 4070
ModalContext$ModalContextThread.block() line: 159
ModalContext.run(IRunnableWithProgress, boolean,
IProgressMonitor, Display) line: 326
ProgressMonitorJobsDialog(ProgressMonitorDialog).run(boolean ,
boolean, IRunnableWithProgress) line: 495
ProgressMonitorJobsDialog.run(boolean, boolean,
IRunnableWithProgress) line: 268
ProgressManager$3.run() line: 909
BusyIndicator.showWhile(Display, Runnable) line: 67
ProgressManager.busyCursorWhile(Runnable,
ProgressMonitorJobsDialog) line: 944
ProgressManager.busyCursorWhile(IRunnableWithProgress) line: 919
ProxyRunnables.runWithBusyCursor(IRunnableWithProgress) line: 83
SourceViewProxy.createSourceView(IWorkbenchPartSite, String,
Composite, IProgressMonitor) line: 67
CurlEditor.establishViewProxy() line: 404
CurlEditor.createSourceViewer(Composite, IVerticalRuler, int)
line: 344

I'm not sure what CurlEditor is doing here. Is it possible to use
Display.asyncExcec to delay this activity?


Farokh Morshed wrote:
> I have been using 3.2.2 and just installed 3.3.1 and tried out our
> plugin. Our plugin has an editor. With 3.3.1 it deadlocks during
> startup. I think it is because I call ProgressManager's
> runWithBusyCursor in the editor's createSourceViewer and when
> runWithBusyCursor starts a new thread to do what I told it to do, and
> before it gets to my code, it does a Display.syncExec. This method
> makes runnables wait until "isStarting" is false.
>
> What's going on here? Am I not supposed to call runWithBusyCursor in
> my editor because it could be called during startup?
>
> Here's the stack frames:
>
>
>
> org.eclipse.equinox.launcher.Main at localhost:1323
> Thread [main] (Suspended)
> OS.WaitMessage() line: not available [native method]
> Display.sleep() line: 4070
> ModalContext$ModalContextThread.block() line: 159
> ModalContext.run(IRunnableWithProgress, boolean,
> IProgressMonitor, Display) line: 326
> ProgressMonitorJobsDialog(ProgressMonitorDialog).run(boolean ,
> boolean, IRunnableWithProgress) line: 495
> ProgressMonitorJobsDialog.run(boolean, boolean,
> IRunnableWithProgress) line: 268
> ProgressManager$3.run() line: 909
> BusyIndicator.showWhile(Display, Runnable) line: 67
> ProgressManager.busyCursorWhile(Runnable,
> ProgressMonitorJobsDialog) line: 944
> ProgressManager.busyCursorWhile(IRunnableWithProgress) line:
> 919
> ProxyRunnables.runWithBusyCursor(IRunnableWithProgress) line:
> 83
> SourceViewProxy.createSourceView(IWorkbenchPartSite, String,
> Composite, IProgressMonitor) line: 67
> CurlEditor.establishViewProxy() line: 404
> CurlEditor.createSourceViewer(Composite, IVerticalRuler, int)
> line: 344
> CurlEditor(AbstractTextEditor).createPartControl(Composite)
> line: 3197
> CurlEditor(StatusTextEditor).createPartControl(Composite)
> line: 53
>
> CurlEditor(AbstractDecoratedTextEditor).createPartControl(Co mposite)
> line: 378
> EditorReference.createPartHelper() line: 661
> EditorReference.createPart() line: 426
> EditorReference(WorkbenchPartReference).getPart(boolean) line:
> 592
> EditorAreaHelper.setVisibleEditor(IEditorReference, boolean)
> line: 263
> EditorManager.setVisibleEditor(IEditorReference, boolean)
> line: 1405
> EditorManager$5.runWithException() line: 939
> EditorManager$5(StartupThreading$StartupRunnable).run() line:
> 31
> RunnableLock.run() line: 35
> UISynchronizer(Synchronizer).runAsyncMessages(boolean) line:
> 123
> Display.runAsyncMessages(boolean) line: 3659
> Display.readAndDispatch() line: 3296
> IDEWorkbenchAdvisor(WorkbenchAdvisor).openWindows() line: 801
> Workbench$25.runWithException() line: 1342
> Workbench$25(StartupThreading$StartupRunnable).run() line: 31
> RunnableLock.run() line: 35
> UISynchronizer(Synchronizer).runAsyncMessages(boolean) line:
> 123
> Display.runAsyncMessages(boolean) line: 3659
> Display.readAndDispatch() line: 3296
> Workbench.runUI() line: 2309
> Workbench.access$4(Workbench) line: 2219
> Workbench$4.run() line: 466
> Realm.runWithDefault(Realm, Runnable) line: 289
> Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor)
> line: 461
> PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor)
> line: 149
> IDEApplication.start(IApplicationContext) line: 106
> EclipseAppHandle.run(Object) line: 169
> EclipseAppLauncher.runApplication(Object) line: 106
> EclipseAppLauncher.start(Object) line: 76
> EclipseStarter.run(Object) line: 363
> EclipseStarter.run(String[], Runnable) line: 176
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[])
> line: not available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
> Method.invoke(Object, Object...) line: 585
> Main.invokeFramework(String[], URL[]) line: 508
> Main.basicRun(String[]) line: 447
> Main.run(String[]) line: 1173
> Main.main(String[]) line: 1148
> Daemon Thread [State Data Manager] (Running)
> Daemon Thread [Framework Event Dispatcher] (Running)
> Daemon Thread [Start Level Event Dispatcher] (Running)
> Thread [Worker-0] (Suspended)
> Object.wait(long) line: not available [native method]
> WorkerPool.sleep(long) line: 185
> WorkerPool.startJob(Worker) line: 217
> Worker.run() line: 51
> Thread [Thread-1] (Suspended)
> Object.wait(long) line: not available [native method]
> RunnableLock(Object).wait() line: 474
> UISynchronizer(Synchronizer).syncExec(Runnable) line: 169
> UISynchronizer.syncExec(Runnable) line: 118
> Display.syncExec(Runnable) line: 4097
>
> StartupThreading.runWithoutExceptions(StartupThreading$Start upRunnable)
> line: 94
> Workbench.init() line: 1337
> Workbench.access$34(Workbench) line: 1274
> Workbench$57.run() line: 2301
> Thread [Thread-2] (Suspended)
> Object.wait(long) line: not available [native method]
> RunnableLock(Object).wait() line: 474
> UISynchronizer(Synchronizer).syncExec(Runnable) line: 169
> UISynchronizer.syncExec(Runnable) line: 118
> Display.syncExec(Runnable) line: 4097
>
> StartupThreading.runWithThrowable(StartupThreading$StartupRu nnable)
> line: 85
> EditorManager.restoreState(IMemento) line: 933
> WorkbenchPage.restoreState(IMemento, IPerspectiveDescriptor)
> line: 3043
> WorkbenchWindow.restoreState(IMemento, IPerspectiveDescriptor)
> line: 2071
> Workbench.doRestoreState(IMemento, MultiStatus) line: 3352
> Workbench.access$32(Workbench, IMemento, MultiStatus) line:
> 3294
> Workbench$53.run() line: 2112
> Workbench.runStartupWithProgress(int, Runnable) line: 1820
> Workbench.restoreState(IMemento) line: 2110
> Workbench.access$30(Workbench, IMemento) line: 2081
> Workbench$48.run() line: 1939
> SafeRunner.run(ISafeRunnable) line: 37
> Workbench.restoreState() line: 1883
> WorkbenchConfigurer.restoreState() line: 183
> WorkbenchAdvisor$1.run() line: 779
> Thread [Curl Eclipse Server] (Running)
> Thread [ModalContext] (Suspended)
> Object.wait(long) line: not available [native method]
> UISynchronizer(Object).wait() line: 474
> UISynchronizer.syncExec(Runnable) line: 108
> Display.syncExec(Runnable) line: 4097
> ModalContext$ModalContextThread.run() line: 134
>
>
Re: Deadlock in my editor during 3.3.1 startup [message #322351 is a reply to message #322345] Wed, 14 November 2007 15:39 Go to previous messageGo to next message
Farokh Morshed is currently offline Farokh MorshedFriend
Messages: 53
Registered: July 2009
Member
Yes, the editor is being invoked during startup because that is how
Eclipse was closed, with an editor open.

The editor is doing something that should take a long time while it must
allow any UI events to be processed. So, it calls ProgressManager's
busyCursorWhile (I mistakenly called it runWithBusyCursor in the original
note) to do it in a different thread and still allow UI events to be
processed.

The editor has to have the results of this operation back in order to load
the file, etc. It cannot asyncExec it.

I can do this on my own by starting a new thread to do the operation and
process the UI event loop myself. But that is what busyCursorWhile is
supposed to do.

So, is calling busyCursorWhile not allowed during startup?
Re: Deadlock in my editor during 3.3.1 startup [message #322353 is a reply to message #322351] Wed, 14 November 2007 16:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Farokh,

Does the CurlEditor(AbstractTextEditor).createPartControl(Composite)
need to wait for the processing to complete before it can return? In
that case, probably avoiding running this on a separate thread at least
for the time being would avoid the problem. Maybe some other folks with
expertise in this area will have better suggestions...


Farokh Morshed wrote:
> Yes, the editor is being invoked during startup because that is how
> Eclipse was closed, with an editor open.
>
> The editor is doing something that should take a long time while it
> must allow any UI events to be processed. So, it calls
> ProgressManager's busyCursorWhile (I mistakenly called it
> runWithBusyCursor in the original note) to do it in a different thread
> and still allow UI events to be processed.
>
> The editor has to have the results of this operation back in order to
> load the file, etc. It cannot asyncExec it.
>
> I can do this on my own by starting a new thread to do the operation
> and process the UI event loop myself. But that is what
> busyCursorWhile is supposed to do.
>
> So, is calling busyCursorWhile not allowed during startup?
Re: Deadlock in my editor during 3.3.1 startup [message #322360 is a reply to message #322353] Wed, 14 November 2007 21:29 Go to previous messageGo to next message
Farokh Morshed is currently offline Farokh MorshedFriend
Messages: 53
Registered: July 2009
Member
The editor has been called to create its window, load the file, etc. It
really can't do this asynchronously. What if some error occurs.

Any how, here is the problem specifically:
1) Start Eclipse such that it needs to restore editors. You can open some
editor
windows, then shutdown Eclipse, then start Eclipse.
2) During Eclipse startup, the editors are restored. If an editor has to
do something that requires busyCursorWhile, then this is what happens:
a) The UI thread starts a new thread to execute the runnable and blocks
(as expected).
b) The new thread executes the runnable (as expected)
c) The new thread in order to make sure that all events in the
asynchronous
event queue are dispatched it ends up in the following code
in UISynchronizer. Because isStarting is true it ends up executing
the this.waiting(); as below.
d) Now, the UI thread is waiting for this thread to complete and we have
a
deadlock. By the way, looking up a little in UISynchronizer, I see
that in the start method there is a call to this.notifyAll(). I don't
know why this is not getting called in time.

public void syncExec(Runnable runnable) {

synchronized (this) {
if (isStarting && UISynchronizer.startupThread.get() == Boolean.FALSE)
{
do {
try {
this.wait();
} catch (InterruptedException e) {
}
} while (isStarting);
}
}
.......
}

I hope this is enough clue for someone familiar with all this to take a
look. The bottom line is: Is it an error to call busyCursorWhile in your
editor? If not, then how can you avoid calling it during startup? Or,
does startup have a bug somewhere?
Re: Deadlock in my editor during 3.3.1 startup [message #322378 is a reply to message #322360] Thu, 15 November 2007 13:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------020700010403070503030901
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Farokh Morshed wrote:
> The editor has been called to create its window, load the file, etc.
> It really can't do this asynchronously. What if some error occurs.
It should be possible to load the file asynchronously. If the error
occurs, you can raise an error box at that time.
>
> Any how, here is the problem specifically:
> 1) Start Eclipse such that it needs to restore editors. You can open
> some editor
> windows, then shutdown Eclipse, then start Eclipse.
> 2) During Eclipse startup, the editors are restored. If an editor has
> to do something that requires busyCursorWhile, then this is what happens:
> a) The UI thread starts a new thread to execute the runnable and
> blocks (as expected).
> b) The new thread executes the runnable (as expected)
> c) The new thread in order to make sure that all events in the
> asynchronous event queue are dispatched it ends up in the
> following code in UISynchronizer. Because isStarting is true it
> ends up executing the this.waiting(); as below.
This does sound kind of bad. Someone from the platform really needs to
comment on this. Opening a bugzilla with a test case that demonstrates
the issue should definitely prompt a response even if the newsgroup
query doesn't.
> d) Now, the UI thread is waiting for this thread to complete and we
> have a deadlock. By the way, looking up a little in
> UISynchronizer, I see that in the start method there is a call to
> this.notifyAll(). I don't
> know why this is not getting called in time.
> public void syncExec(Runnable runnable) {
>
> synchronized (this) {
> if (isStarting && UISynchronizer.startupThread.get() ==
> Boolean.FALSE) {
This looks a little suspect to me

UISynchronizer.startupThread.get() == Boolean.FALSE

given that you can do new Boolean(false), but I suppose they know that's
not being done:
> do {
> try {
> this.wait();
> } catch (InterruptedException e) {
> }
> } while (isStarting);
> }
> }
> .......
> }
>
> I hope this is enough clue for someone familiar with all this to take
> a look. The bottom line is: Is it an error to call busyCursorWhile
> in your editor? If not, then how can you avoid calling it during
> startup? Or, does startup have a bug somewhere?
This does all seem quite suspect to me. It sounds like you could
reproduce this problem with a trivial editor and open a bugzilla with
that test case. That's bound to get a response from the development
experts...


--------------020700010403070503030901
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Farokh Morshed wrote:
<blockquote
cite="mid:5df61e41580bff9654812c0634a8fd70$1@www.eclipse.org"
type="cite">The editor has been called to create its window, load the
file, etc.
Re: Deadlock in my editor during 3.3.1 startup [message #322389 is a reply to message #322378] Thu, 15 November 2007 16:27 Go to previous message
Farokh Morshed is currently offline Farokh MorshedFriend
Messages: 53
Registered: July 2009
Member
I will report this as a bug with a reference to this note and if they
really want an example I can make one up.

Thanks Ed for the guidance. I owe you one.

I have implemented a workaround. When I am getting reading to call the
busyCursorWhile method I call the workbench's isStarting method. If it is
true, I do my own implementation of busyCursorWhile without a busy cursor.
That is, I just start a new thread to do what I need to do, wait for it
to finish, while processing the event queue. The problem with this
workaround is that although isStarting() is public, it is not included in
the public workbench interface. I have to import
org.eclipse.ui.internal.Workbench which is really not allowed.

farokh
Previous Topic:Help with java project export then import.
Next Topic:Content types, contentTypeBinding
Goto Forum:
  


Current Time: Thu Aug 08 22:37:00 GMT 2024

Powered by FUDForum. Page generated in 0.03975 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top