Преглед изворни кода

Fix late access to codelet freed by data_unregister

Samuel Thibault пре 8 година
родитељ
комит
69fe1a85a9
1 измењених фајлова са 6 додато и 1 уклоњено
  1. 6 1
      src/core/jobs.c

+ 6 - 1
src/core/jobs.c

@@ -272,6 +272,11 @@ void _starpu_handle_job_termination(struct _starpu_job *j)
 		0
 		0
 #endif
 #endif
 		;
 		;
+	/* Read cl fields before releasing dependencies, for the case of a
+	 * switch_cl which is freed by data_unregister happening as soon as
+	 * the dependencies are released.
+	 */
+	unsigned nowhere = !task->cl || task->cl->where == STARPU_NOWHERE;
 
 
 #ifdef STARPU_DEBUG
 #ifdef STARPU_DEBUG
 	STARPU_PTHREAD_MUTEX_LOCK(&all_jobs_list_mutex);
 	STARPU_PTHREAD_MUTEX_LOCK(&all_jobs_list_mutex);
@@ -340,7 +345,7 @@ void _starpu_handle_job_termination(struct _starpu_job *j)
 	 * scheduler to process it : the task structure doesn't contain any valuable
 	 * scheduler to process it : the task structure doesn't contain any valuable
 	 * data as it's not linked to an actual worker */
 	 * data as it's not linked to an actual worker */
 	/* control task should not execute post_exec_hook */
 	/* control task should not execute post_exec_hook */
-	if(j->task_size == 1 && task->cl != NULL && task->cl->where != STARPU_NOWHERE && !j->internal
+	if(j->task_size == 1 && !nowhere && !j->internal
 #ifdef STARPU_OPENMP
 #ifdef STARPU_OPENMP
 	/* If this is a continuation, we do not execute the post_exec_hook. The
 	/* If this is a continuation, we do not execute the post_exec_hook. The
 	 * post_exec_hook will be run only when the continued task fully
 	 * post_exec_hook will be run only when the continued task fully