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

Bug 183286

Summary: JobManager can get into a state where same job is running in two threads at once
Product: [Eclipse Project] Platform Reporter: John Arthorne <john.arthorne>
Component: RuntimeAssignee: John Arthorne <john.arthorne>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P1    
Version: 3.3   
Target Milestone: 3.3 M7   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
Fix none

Description John Arthorne CLA 2007-04-19 17:14:03 EDT
Build: 3.3 M6

On multi-processor machines, the JobManager can get into a state where the same job is running in two threads at once. Here is the sequence of events:

1) Job is scheduled
2) Thread 1 removes job from wait queue in JobManager.nextJob, sets state to ABOUT_TO_RUN
3) After exit of synchronized block in nextJob, another thread calls cancel on the job
4) JobManager#cancel(InternalJob) sets the job state to NONE
5) Same job is scheduled again
6) Thread 2 removes job from wait queue in JobManager.nextJob, and sets state to ABOUT_TO_RUN
7) Now Thread 1 resumes control, and since the state is ABOUT_TO_RUN as expected, execution of the job commences
8) Thread 2 also finds the job to be in a good state, and starts running it.

Among other things, this resulted in bug 170890 where the job's progress monitor is null in the job's run method (because the monitor was set to null when a job completed, but another thread was still running the job).
Comment 1 John Arthorne CLA 2007-04-19 17:15:25 EDT
Testing a fix...
Comment 2 John Arthorne CLA 2007-04-19 17:16:20 EDT
Created attachment 64357 [details]
Fix
Comment 3 John Arthorne CLA 2007-04-19 17:30:18 EDT
Fix released.