NullReferenceException in ParallelTask still happen after fix applied

Added by Hwee Miin Koh about 4 years ago

Regarding Bug#173 and Bug#187, after applying the fix at
http://www.cruisecontrolnet.org/projects/ccnet/repository/revisions/efcd9109e5b093e41b5298151bc9a6a914431d1f

I still see it happening in our build system once every few months. It is extremely hard to reproduce, so I just keep scanning through the code hoping to find anything suspicious, and following is what I found:
In ParallelTask.cs line 225 ~ 234

@
events[taskNumber].Set();
tasksDetails[taskNumber].Finished = true;
tasksDetails[taskNumber].ParentResult.BuildProgressInformation.UpdateStartupInformation(GetStatusInformation(tasksDetails[taskNumber]));
}, loop);
}

logger.Debug("Waiting for tasks to complete");
WaitHandle.WaitAll(events);
@

Because the event is set before the worker-thread actually ended (there are still 2 line of code to run after that), it is possible that the main-thread continue to run before the worker-thread ended. Thus, in extreme case, it is possible that CCNet declares the integration as completed even though some of the worker-thread still running, and when CCNet starts another integration using the same project, where it allocate new taskDetails array at ParallelTask.cs line 168:


tasksDetails = new ParallelRunningSubTaskDetails[numberOfTasks];

If the previous unfinished worker-thread continue to run the last 2 line of its code, which involve calling to GetStatusInformation():


events[taskNumber].Set();
tasksDetails[taskNumber].Finished = true;
tasksDetails[taskNumber].ParentResult.BuildProgressInformation.UpdateStartupInformation(GetStatusInformation(tasksDetails[taskNumber]));

It might encounter NullReferenceException on accessing taskDetails.

But this is all theory, the case is too difficult to be reproduced. I'll need someone to verify whether my theory is possible? Or did anyone encounter similar error also after the applying fix?

Thanks!


Replies (1)

RE: NullReferenceException in ParallelTask still happen after fix applied - Added by Olivier Sannier almost 4 years ago

Hello,

After applying the fix, I did not get any crashes any more.
However, you can test your solution by compiling CCNet yourself.

(1-1/1)