Skip to contentSkip to conversation

Fix a SEGV due to uninitialised mask

PATCH In review Daniel J Blueman 2 participants 2 messages Feb 17, 2015 – Feb 18, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix a SEGV due to uninitialised mask

As node_cpu_mask_v2 is not defined as local to the compilation unit with 'static', it is not guaranteed to be initialised to zero (ie in the .bss). This was leading to some SEGVs we've seen.

Also mark another internal function local to the compilation unit.

---
 libnuma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libnuma.c +2 -2
index 8d7bf13..3717d5b 100644
@@ -58,7 +58,7 @@ struct bitmask *numa_possible_cpus_ptr = NULL;
 struct bitmask *numa_nodes_ptr = NULL;
 static struct bitmask *numa_memnode_ptr = NULL;
 static unsigned long *node_cpu_mask_v1[NUMA_NUM_NODES];
-struct bitmask **node_cpu_mask_v2;
+static struct bitmask **node_cpu_mask_v2;
 
 WEAK void numa_error(char *where);
 
@@ -1234,7 +1234,7 @@ numa_parse_bitmap_v2(char *line, struct bitmask *mask)
 __asm__(".symver numa_parse_bitmap_v2,numa_parse_bitmap@@libnuma_1.2");
 
 void
-init_node_cpu_mask_v2(void)
+static init_node_cpu_mask_v2(void)
 {
 	int nnodes = numa_max_possible_node_v2_int() + 1;
 	node_cpu_mask_v2 = calloc (nnodes, sizeof(struct bitmask *));
Signature · 1 line
1.9.1
#1 lore raw

Hi,

Quoted 7 lines · Daniel J Blueman

As node_cpu_mask_v2 is not defined as local to the compilation unit with 'static', it is not guaranteed to be initialised to zero (ie in the .bss). This was leading to some SEGVs we've seen.

Also mark another internal function local to the compilation unit.

Pushed. Thanks for the contribution!

Cheers,
Filipe