MATLAB: PCT : cannot cancel a running job without a PCT chrash

crashjobsParallel Computing Toolbox

Hello
I think i have an infinite loop running in a worker. Each time i try to cancel it, PCT crashes. When i restart parallel pool with :
if isempty(gcp('nocreate'))
p = parpool(1);
else
p = gcp('nocreate');
end
and then i ask for jobs with :
p.Cluster.Jobs
which gives :
ans =
Job
Properties:
ID: 1
Type: concurrent
Username: blafa
State: running
SubmitDateTime: 02-Apr-2019 14:49:24
StartDateTime: 02-Apr-2019 14:49:33
Running Duration: 0 days 0h 14m 47s
NumWorkersRange: [1 1]
AutoAttachFiles: true
Auto Attached Files: List files
AutoAddClientPath: true
AttachedFiles: {}
AdditionalPaths: 9 paths
Associated Tasks:
Number Pending: 0
Number Running: 1
Number Finished: 0
Task ID of Errors: []
Task ID of Warnings: []
when i try to cancel it, PCT crashes :
p.Cluster.Jobs.cancel
The client lost connection to worker 1. This might be due to network problems, or the interactive communicating job might have
errored.

Best Answer

When you run a parallel pool, PCT uses a parallel.Job behind the scenes to launch and co-ordinate the workers. By directly cancelling that Job, you're asking the PCT Cluster object to forcibly terminate all the worker processes. This causes the parallel pool session to abort, because the workers have been shut down. This is precisely what you're seeing here.
Could I ask: where is the actual problem you're encountering?