Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch View: "Terminate and Relaunch" sometimes does not relaunch all processes of a Launch Group #1318

Closed
jukzi opened this issue Apr 17, 2024 · 1 comment · Fixed by #1381
Labels
bug Something isn't working

Comments

@jukzi
Copy link
Contributor

jukzi commented Apr 17, 2024

In the launch View selecting a running launch group and choosing "Terminate and Relaunch" from the contet menu sometimes fails to relaunch the whole group or some of the processes.
image

After that the launch view shows two nodes for the launchgroup, both showing the same - terminated - PIDs:
image

Reproducable with a simple Program like:

public class Main {
	public static void main(String[] args) {
		while (true) {}
	}
}

Create 2 launches for the Program (just create 1 and duplicate it).
Create 1 launchgroup to start both launches.
Set option "adopt if runing"
image

"run" the launch group,
image

"Terminate and Relaunch" the launch group. Sometimes it is not fully relaunched:
image

I have only seen it failing when option "adopt if runing" was used.

@jukzi jukzi added the bug Something isn't working label Apr 17, 2024
@jukzi
Copy link
Contributor Author

jukzi commented May 17, 2024

It's a race condition:

GroupLaunchElement.adoptIfRunning was introduced to:

"allows to skip launching that configuration in case it is already running, launched either manually or by another group.
This allows to prevent duplicate launches for certain configurations."

TerminateAndRelaunchAction first terminates the processes

Thread [Worker-17: Execute Debug Command] (Suspended)	
	owns: HashMap<K,V>  (id=561)	
	ProcessImpl.destroy() line: 607	
	RuntimeProcess.terminate() line: 265	
	Launch.terminate() line: 287	
	GroupLaunch.terminate() line: 155	
	TerminateCommand.execute(Object) line: 35	
	TerminateCommand(ForEachCommand).doExecute(Object[], IProgressMonitor, IRequest) line: 36	
	AbstractDebugCommand$1.run(IProgressMonitor) line: 215	
	Worker.run() line: 63	

And later uses org.eclipse.debug.core.model.RuntimeProcess.fTerminated to identify if the launch is already/still running

But that flag is only set asynchronous in org.eclipse.debug.core.model.RuntimeProcess.ProcessMonitorThread after the ProcessMonitor has terminated:

Daemon Thread [Process monitor for PID 22980 Main] (Suspended (breakpoint at line 334 in RuntimeProcess))	
	RuntimeProcess.terminated() line: 334	
	RuntimeProcess$ProcessMonitorThread.run() line: 516	

solution: synchronously remember thread is terminated after terminating it

jukzi pushed a commit to jukzi/eclipse.platform that referenced this issue May 17, 2024
…e-platform#1318

This was a race condition:
RuntimeProcess.fTerminated was only set asynchronously, hindering
relaunching the process, thinking it was already running.

Happened only for GroupLaunchElement.adoptIfRunning == true

fixes
eclipse-platform#1318
jukzi pushed a commit to jukzi/eclipse.platform that referenced this issue May 27, 2024
…e-platform#1318

This was a race condition:
RuntimeProcess.fTerminated was only set asynchronously, hindering
relaunching the process, thinking it was already running.

Happened only for GroupLaunchElement.adoptIfRunning == true

fixes
eclipse-platform#1318
jukzi pushed a commit to jukzi/eclipse.platform that referenced this issue Jun 6, 2024
…e-platform#1318

This was a race condition:
RuntimeProcess.fTerminated was only set asynchronously, hindering
relaunching the process, thinking it was already running.

Happened only for GroupLaunchElement.adoptIfRunning == true

fixes
eclipse-platform#1318
jukzi pushed a commit to jukzi/eclipse.platform that referenced this issue Jun 6, 2024
…e-platform#1318

This was a race condition:
RuntimeProcess.fTerminated was only set asynchronously, hindering
relaunching the process, thinking it was already running.

Happened only for GroupLaunchElement.adoptIfRunning == true

fixes
eclipse-platform#1318
jukzi pushed a commit that referenced this issue Jun 6, 2024
This was a race condition:
RuntimeProcess.fTerminated was only set asynchronously, hindering
relaunching the process, thinking it was already running.

Happened only for GroupLaunchElement.adoptIfRunning == true

fixes
#1318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant