From a0243ab12a9cdab191c624ef23e035d97f08d60e Mon Sep 17 00:00:00 2001 From: Pierre-Marc Fournier Date: Mon, 1 Feb 2010 21:43:03 -0500 Subject: [PATCH] _SC_NPROCESSORS_ONLN -> _SC_NPROCESSORS_CONF --- libust/buffers.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libust/buffers.c b/libust/buffers.c index 13660a89..7d2dd473 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; } -- 2.34.1