X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=libust%2Fbuffers.c;h=241ca74d4172160000c3dbed8840acf617a90bde;hb=120b0ec33d0c9052f3b4db2199a2dd20ed5fd00e;hp=13660a8910402ad45e163c524aa845d37025a6df;hpb=204141ee9da22a244c9095287f4f1c513784b171;p=ust.git diff --git a/libust/buffers.c b/libust/buffers.c index 13660a8..241ca74 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; } @@ -210,6 +218,7 @@ int ust_buffers_channel_open(struct ust_channel *chan, size_t subbuf_size, size_ for(; i>=0; i--) { ust_buffers_close_buf(chan->buf[i]); error: + do {} while(0); } kref_put(&chan->kref, ust_buffers_destroy_channel);