$ cat f.c #include <stdio.h> extern int __get_nprocs_sched (void); int main() { printf("%d\n", __get_nprocs_sched()); } $ gcc -static f.c -o f $ ./f 828 $ ./f 794 $ nproc 8 sched_getaffinity(2) writes first N bits of cpu_bits array, but the rest of it is left uninitialized.
Fixed in 2.36: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=97ba273b505763325efd802dc3a9562dbba79579