X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=libust%2Fbuffers.c;h=7d2dd47336ecfda237a6d6564b99f2bca38f3000;hb=a0243ab12a9cdab191c624ef23e035d97f08d60e;hp=13660a8910402ad45e163c524aa845d37025a6df;hpb=204141ee9da22a244c9095287f4f1c513784b171;p=ust.git diff --git a/libust/buffers.c b/libust/buffers.c index 13660a8..7d2dd47 100644 --- a/libust/buffers.c +++ b/libust/buffers.c @@ -45,7 +45,15 @@ static int get_n_cpus(void) return n_cpus; } - result = sysconf(_SC_NPROCESSORS_ONLN); + /* On Linux, when some processors are offline + * _SC_NPROCESSORS_CONF counts the offline + * processors, whereas _SC_NPROCESSORS_ONLN + * does not. If we used _SC_NPROCESSORS_ONLN, + * getcpu() could return a value greater than + * this sysconf, in which case the arrays + * indexed by processor would overflow. + */ + result = sysconf(_SC_NPROCESSORS_CONF); if(result == -1) { return -1; }