On Fri, Oct 15, 2021 at 12:26:34PM -0700, sunil.k.pandey wrote: > 4764049dd620affcd3e2658dc7f03a6616370a29 is the first bad commit > commit 4764049dd620affcd3e2658dc7f03a6616370a29 > Author: Jakub Jelinek <ja...@redhat.com> > Date: Fri Oct 15 16:25:25 2021 +0200 > > openmp: Fix up handling of OMP_PLACES=threads(1) > > caused > > FAIL: libgomp.c/places-10.c execution test
Reproduced on gcc112 in CompileFarm (my ws isn't NUMA). If numa-domains is used with num-places count, sometimes the function could create more places than requested and crash. This depended on the content of /sys/devices/system/node/online file, e.g. if the file contains 0-1,16-17 and all NUMA nodes contain at least one CPU in the cpuset of the program, then numa_domains(2) or numa_domains(4) (or 5+) work fine while numa_domains(1) or numa_domains(3) misbehave. I.e. the function was able to stop after reaching limit on the , separators (or trivially at the end), but not within in the ranges. Fixed thusly, tested on powerpc64le-linux, committed to trunk. 2021-10-18 Jakub Jelinek <ja...@redhat.com> * config/linux/affinity.c (gomp_affinity_init_numa_domains): Add && gomp_places_list_len < count after nfirst <= nlast loop condition. --- libgomp/config/linux/affinity.c.jj 2021-10-15 16:28:30.374460522 +0200 +++ libgomp/config/linux/affinity.c 2021-10-18 14:44:51.559667127 +0200 @@ -401,7 +401,7 @@ gomp_affinity_init_numa_domains (unsigne break; q = end; } - for (; nfirst <= nlast; nfirst++) + for (; nfirst <= nlast && gomp_places_list_len < count; nfirst++) { sprintf (name + prefix_len, "node%lu/cpulist", nfirst); f = fopen (name, "r"); Jakub