Explorar o código

Avoid overflow e.g. in num_threads_list allocation

Samuel Thibault %!s(int64=9) %!d(string=hai) anos
pai
achega
11f734248e
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      src/util/openmp_runtime_support_environment.c

+ 4 - 0
src/util/openmp_runtime_support_environment.c

@@ -682,6 +682,10 @@ static void read_omp_environment(void)
 	read_int_var("OMP_DEFAULT_DEVICE", &_initial_icv_values.default_device_var);
 	read_int_var("OMP_MAX_TASK_PRIORITY", &_initial_icv_values.max_task_priority_var);
 
+	/* Avoid overflow e.g. in num_threads_list allocation */
+	STARPU_ASSERT_MSG(_initial_icv_values.max_active_levels_var > 0 && _initial_icv_values.max_active_levels_var < 1000000, "OMP_MAX_ACTIVE_LEVELS should have a reasonable value");
+	/* TODO: check others */
+
 	const int max_levels = _initial_icv_values.max_active_levels_var;
 
 	/* read OMP_PROC_BIND */