Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344739

Summary: RejectedExecutionException thrown when terminating a launch
Product: [Tools] CDT Reporter: Norman Yee <normankyee>
Component: cdt-debug-dsfAssignee: Marc Khouzam <marc.khouzam>
Status: RESOLVED FIXED QA Contact: Pawel Piech <pawel.1.piech>
Severity: normal    
Priority: P3 CC: andrew.mclachlan, cdtdoug, marc.khouzam, nobody
Version: 7.0   
Target Milestone: 8.5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Norman Yee CLA 2011-05-04 13:31:16 EDT
Build Identifier: I20110310-1119

If I launch a debug configuration, terminate the launch, re-launch the debug configuration and then terminate it again, I see that the RejectedExecutionException is thrown.  Here is the call stack:

!ENTRY org.eclipse.debug.ui 4 120 2011-05-04 13:24:12.616
!MESSAGE Error logged from Debug UI: 
!STACK 0
java.util.concurrent.RejectedExecutionException
	at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.reject(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(Unknown Source)
	at org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor.schedule(DefaultDsfExecutor.java:434)
	at java.util.concurrent.ScheduledThreadPoolExecutor.submit(Unknown Source)
	at org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor.submit(DefaultDsfExecutor.java:466)
	at org.eclipse.cdt.dsf.debug.ui.actions.DsfResumeCommand.canExecute(DsfResumeCommand.java:51)
	at org.eclipse.debug.internal.ui.commands.actions.DebugCommandService.updateCommand(DebugCommandService.java:182)
	at org.eclipse.debug.internal.ui.commands.actions.DebugCommandService.postUpdate(DebugCommandService.java:153)
	at org.eclipse.debug.internal.ui.commands.actions.DebugCommandService.debugContextChanged(DebugCommandService.java:245)
	at org.eclipse.debug.internal.ui.contexts.DebugWindowContextService$1.run(DebugWindowContextService.java:194)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.debug.internal.ui.contexts.DebugWindowContextService.notify(DebugWindowContextService.java:192)
	at org.eclipse.debug.internal.ui.contexts.DebugWindowContextService.notify(DebugWindowContextService.java:181)
	at org.eclipse.debug.internal.ui.contexts.DebugWindowContextService.debugContextChanged(DebugWindowContextService.java:390)
	at org.eclipse.debug.ui.contexts.AbstractDebugContextProvider$1.run(AbstractDebugContextProvider.java:79)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.debug.ui.contexts.AbstractDebugContextProvider.fire(AbstractDebugContextProvider.java:77)
	at org.eclipse.debug.internal.ui.views.launch.LaunchView$ContextProviderProxy.debugContextChanged(LaunchView.java:475)
	at org.eclipse.debug.ui.contexts.AbstractDebugContextProvider$1.run(AbstractDebugContextProvider.java:79)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.debug.ui.contexts.AbstractDebugContextProvider.fire(AbstractDebugContextProvider.java:77)
	at org.eclipse.debug.internal.ui.views.launch.LaunchView$TreeViewerContextProvider.possibleChange(LaunchView.java:366)
	at org.eclipse.debug.internal.ui.views.launch.LaunchView$TreeViewerContextProvider$Visitor.visit(LaunchView.java:289)
	at org.eclipse.cdt.dsf.ui.viewmodel.VMDelta.doAccept(VMDelta.java:355)
	at org.eclipse.cdt.dsf.ui.viewmodel.VMDelta.doAccept(VMDelta.java:358)
	at org.eclipse.cdt.dsf.ui.viewmodel.VMDelta.accept(VMDelta.java:350)
	at org.eclipse.debug.internal.ui.views.launch.LaunchView$TreeViewerContextProvider.modelChanged(LaunchView.java:394)
	at org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider.doModelChanged(ModelContentProvider.java:1390)
	at org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider.modelChanged(ModelContentProvider.java:1364)
	at org.eclipse.cdt.dsf.ui.viewmodel.DefaultVMModelProxyStrategy$1.run(DefaultVMModelProxyStrategy.java:144)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.cdt.dsf.ui.viewmodel.DefaultVMModelProxyStrategy.fireModelChanged(DefaultVMModelProxyStrategy.java:148)
	at org.eclipse.cdt.dsf.ui.viewmodel.update.AbstractCachingVMProvider$6.handleSuccess(AbstractCachingVMProvider.java:881)
	at org.eclipse.cdt.dsf.concurrent.RequestMonitor.handleCompleted(RequestMonitor.java:353)
	at org.eclipse.cdt.dsf.concurrent.RequestMonitor$2.run(RequestMonitor.java:298)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4125)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3742)
	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)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

It looks like it's trying to update the DsfResumeCommand after the session is terminated?  I've also seen it throw the same exception while trying to update the DsfSuspendCommand and DsfStepIntoCommand.

I am using a custom DSF debugger plugin if it makes any difference.

Reproducible: Always

Steps to Reproduce:
1. Launch a debug configuration
2. Terminate it
3. Launch a debug configuration
4. Terminate it.  Now I see the RejectedExecutionException thrown.
Comment 1 Norman Yee CLA 2011-09-23 16:27:14 EDT
I can reproduce the problem with the PDA DSF example.  Just launch a PDA launch configuration, terminate it, and you'll see the RejectedExecutionException exception in the Error Log view.
Comment 2 Andrew McLachlan CLA 2014-07-04 07:43:31 EDT
Any news on a fix for this Issue?
Comment 3 Marc Khouzam CLA 2014-07-04 13:37:22 EDT
I can reproduce this with the PDA launch.

The problem is that the DSF executor is being shutdown too early.  When the platform makes calls to update the UI buttons after the launch is terminated, the executor is not there any more and the exception is thrown.

In GdbLaunch, we only shutdown the executor when the launch is removed from the debug view, not when the launch is terminated.

I pushed a patch to Gerrit to do the same in the PDA launch:
  https://git.eclipse.org/r/29488

My guess is that your custom DSF debugger makes the same mistake.
Comment 4 Marc Khouzam CLA 2014-07-04 13:39:09 EDT
Mikhail, I believe you use the PDA example once in a while, can you have a look at this fix?  It is a couple of lines only and maps directly to what we don in GdbLaunch.
Comment 5 Nobody - feel free to take it CLA 2014-07-04 15:58:11 EDT
(In reply to Marc Khouzam from comment #4)
> Mikhail, I believe you use the PDA example once in a while, can you have a
> look at this fix?  It is a couple of lines only and maps directly to what we
> don in GdbLaunch.

Mark, I have never been able to make the PDA example run. I can review the code without trying it though.
Comment 6 Marc Khouzam CLA 2014-07-04 16:08:36 EDT
(In reply to Mikhail Khodjaiants from comment #5)
> (In reply to Marc Khouzam from comment #4)
> > Mikhail, I believe you use the PDA example once in a while, can you have a
> > look at this fix?  It is a couple of lines only and maps directly to what we
> > don in GdbLaunch.
> 
> Mark, I have never been able to make the PDA example run.

Yeah, I'm not very familiar with it.  This is what I did:

1- create test.pl at the root of any of your test projects with the line:
  print allo
2- create a new launch configuration using the PDA launch configuration type.
3- use test.pl as the program in the Main tab (e.g., /HelloWorld/test.pl)
4- launch

Not everything seems to work, but it does launch for me

>  I can review the code without trying it though.

That is fine for me.  The change is in an example and a copy of code we know works.
Comment 7 Norman Yee CLA 2014-07-07 10:13:50 EDT
Thanks Marc!  I applied the same fix to my debugger plugin and I don't see the exception any more.
Comment 8 Marc Khouzam CLA 2014-07-07 10:23:07 EDT
(In reply to Norman Yee from comment #7)
> Thanks Marc!  I applied the same fix to my debugger plugin and I don't see
> the exception any more.

That is great.  I think that confirms the validity of the fix so I have committed it to master.

Mikhail, that should save you some time as this review was not very important, but your comments are always welcomed, as usual.