소스 검색

Fix use-after-free when the just-released task terminates before it is used by starpu_sched_ctx_list_task_counters_increment_all_ctx_locked

Samuel Thibault 8 년 전
부모
커밋
12e0b4d168
1개의 변경된 파일10개의 추가작업 그리고 10개의 파일을 삭제
  1. 10 10
      src/sched_policies/eager_central_priority_policy.c

+ 10 - 10
src/sched_policies/eager_central_priority_policy.c

@@ -90,6 +90,16 @@ static int _starpu_priority_push_task(struct starpu_task *task)
 	STARPU_PTHREAD_MUTEX_LOCK(&data->policy_mutex);
 	_starpu_worker_relax_off();
 	_starpu_prio_deque_push_back_task(taskq, task);
+
+	if (_starpu_get_nsched_ctxs() > 1)
+	{
+		_starpu_worker_relax_on();
+		_starpu_sched_ctx_lock_write(sched_ctx_id);
+		_starpu_worker_relax_off();
+		starpu_sched_ctx_list_task_counters_increment_all_ctx_locked(task, sched_ctx_id);
+		_starpu_sched_ctx_unlock_write(sched_ctx_id);
+	}
+
 	starpu_push_task_end(task);
 
 	/*if there are no tasks block */
@@ -140,16 +150,6 @@ static int _starpu_priority_push_task(struct starpu_task *task)
 	}
 #endif
 
-	if (_starpu_get_nsched_ctxs() > 1)
-	{
-		_starpu_worker_relax_on();
-		_starpu_sched_ctx_lock_write(sched_ctx_id);
-		_starpu_worker_relax_off();
-		starpu_sched_ctx_list_task_counters_increment_all_ctx_locked(task, sched_ctx_id);
-		_starpu_sched_ctx_unlock_write(sched_ctx_id);
-	}
-
-
 	return 0;
 }