While this is not an issue yet, sgen_thread_pool_wait_for_all_jobs is logically expected to be called by the main thread and resume execution after all jobs have been executed. Concurrent M&S can enqueue additional jobs as part of its finishing phase, which means that we could detect early that no more jobs are to be processed. Make sure this is not the case.
{
WorkerContext *context = &worker_contexts [generation];
+ mono_os_mutex_lock (&context->finished_lock);
context->finish_callback = NULL;
- mono_memory_write_barrier ();
+ mono_os_mutex_unlock (&context->finished_lock);
+
context->forced_stop = TRUE;
sgen_thread_pool_wait_for_all_jobs (context->thread_pool_context);
WorkerContext *context = &worker_contexts [generation];
int i;
+ SGEN_ASSERT (0, !context->finish_callback, "Why are we joining concurrent mark early");
/*
* It might be the case that a worker didn't get to run anything
* in this context, because it was stuck working on a long job