浏览代码

papi: make sure we do not overflow the papi_events array

Samuel Thibault 4 年之前
父节点
当前提交
8185c2e40b
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/profiling/profiling.c

+ 7 - 1
src/profiling/profiling.c

@@ -165,7 +165,13 @@ void _starpu_profiling_init(void)
 		{
 			while ((papi_event_name = strtok_r(conf_papi_events, " ,", &conf_papi_events)))
 			{
-				_STARPU_DEBUG("Loading PAPI Event:%s\n", papi_event_name);
+				if (papi_nevents == PAPI_MAX_HWCTRS)
+				{
+				      _STARPU_MSG("Too many requested papi counters, ignoring %s\n", papi_event_name);
+				      continue;
+				}
+
+				_STARPU_DEBUG("Loading PAPI Event: %s\n", papi_event_name);
 				retval = PAPI_event_name_to_code ((char*)papi_event_name, &papi_events[papi_nevents]);
 				if (retval != PAPI_OK)
 				      _STARPU_MSG("Failed to codify papi event [%s], error: %s.\n", papi_event_name, PAPI_strerror(retval));