Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 527341 - Threading problem in JobGroup.join() (through text search that is triggered at startup of eclipse)
Summary: Threading problem in JobGroup.join() (through text search that is triggered a...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.7.1a   Edit
Hardware: PC Windows NT
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-16 07:50 EST by Johan Compagner CLA
Modified: 2020-05-15 13:21 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Compagner CLA 2017-11-16 07:50:47 EST
This looks a lot like:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=461621

That one seems to be in resolved/fixed but my case is for sure not fixed, i do get the exact same result:

	Daemon Thread [org.eclipse.dltk.internal.ui.text.ScriptReconciler] (Suspended)	
	owns: Object  (id=225)	
	MultiStatus.addAll(IStatus) line: 92	
	TextSearchVisitor.search(IFile[], IProgressMonitor) line: 409	
	TextSearchVisitor.search(TextSearchScope, IProgressMonitor) line: 428	
	TextSearchEngine$1.search(TextSearchScope, TextSearchRequestor, Pattern, IProgressMonitor) line: 57	

so the status given there is null because the jobGroup.getResult() call in TextSearchVisitor is still null:

				jobGroup.join(0, null);
				if (fProgressMonitor.isCanceled())
					throw new OperationCanceledException(SearchMessages.TextSearchVisitor_canceled);

				fStatus.addAll(jobGroup.getResult());

this is because if i place a break point here: (on the break line, JobManager.join:1034):

synchronized (lock) {
    if ((suspended && jobGroup.getRunningJobsCount() == 0))
       break;
}

So i get this stack:

	JobManager.join(InternalJobGroup, long, IProgressMonitor) line: 1034	
	TextSearchVisitor$TextSearchJobGroup(InternalJobGroup).join(long, IProgressMonitor) line: 93	
	TextSearchVisitor$TextSearchJobGroup(JobGroup).join(long, IProgressMonitor) line: 234	
	TextSearchVisitor.search(IFile[], IProgressMonitor) line: 405	
	TextSearchVisitor.search(TextSearchScope, IProgressMonitor) line: 428	
	TextSearchEngine$1.search(TextSearchScope, TextSearchRequestor, Pattern, IProgressMonitor) line: 57	

then it will break there and if i then let it pass the break, so it releases the lock on that lock object:

i get in another worker thread this stack (because of the break point i added there):

	Thread [Worker-10] (Suspended (breakpoint at line 129 in InternalJobGroup))	
	owns: Object  (id=224)	
	TextSearchVisitor$TextSearchJobGroup(InternalJobGroup).jobStateChanged(InternalJob, int, int) line: 129	
	JobManager.changeState(InternalJob, int) line: 468	
	JobManager.nextJob() line: 1129	
	JobManager.startJob(Worker) line: 1603	
	WorkerPool.startJob(Worker) line: 214	
	Worker.run() line: 52	

so only then the next job is taken and the state is changed to "running"


I guess the problem is that the JobManager is still in suspend mode, because eclipse is starting up.
But i can't really help this because this as an javascript editor  that is already opened by eclipse and that already tries to reconsile the script (that results in searching for something)

So or i have to somehow be able to say to that JobManager that it should start doing stuff. Or join() should always wait for it even if the jobmanager for now is suspended.

Because that code displayed above is before the test if there are jobs (running or active)
Comment 1 Johan Compagner CLA 2017-11-16 07:58:52 EST
i "fixed" it now by doing in our code just before i kick of the TextSearch:

if (Job.getJobManager().isSuspended())
{
   Job.getJobManager().resume();
}

but that doesn't really feel right...
Comment 2 Eclipse Genie CLA 2020-05-15 13:21:32 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.