I finally broke down and used GDB. RLIMIT_DATA and RLIMIT_AS appear to be set to 10,000,000. An attempt to malloc 10 million (MAX_ALLOC_TOTAL) fails and the two failing tests exit with status "1". After reading the man page for getrlimit and looking at this code, my question is, "Why would you expect this to *NOT* fail?" After all, assuming that any heap space at all has been allocated, an attempt to allocate the full size of the address and/or data space is surely going to fail. What else can be expected?
If your intent is to squeeze the heap so that printf fails on an allocation, perhaps you want to allocate a large chunk and then allocate little nibbles until you fail, *THEN* try the printf call, yes? Breakpoint 1, main (argc=2, argv=0x7fffffffdd38) at ../../tests/test-fprintf-posix3.c:57 57 if (getrlimit (RLIMIT_DATA, &limit) < 0) (gdb) 59 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > MAX_ALLOC_TOTAL) (gdb) 60 limit.rlim_max = MAX_ALLOC_TOTAL; (gdb) 61 limit.rlim_cur = limit.rlim_max; (gdb) 62 if (setrlimit (RLIMIT_DATA, &limit) < 0) (gdb) p limit $1 = {rlim_cur = 10000000, rlim_max = 10000000} (gdb) n 67 if (getrlimit (RLIMIT_AS, &limit) < 0) (gdb) 69 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > MAX_ALLOC_TOTAL) (gdb) 70 limit.rlim_max = MAX_ALLOC_TOTAL; (gdb) 71 limit.rlim_cur = limit.rlim_max; (gdb) 72 if (setrlimit (RLIMIT_AS, &limit) < 0) (gdb) p limit $2 = {rlim_cur = 10000000, rlim_max = 10000000} (gdb) n 76 arg = atoi (argv[1]); (gdb) 77 if (arg == 0) (gdb) p arg $3 = 0 (gdb) n 79 void *memory = malloc (MAX_ALLOC_TOTAL); (gdb) 80 if (memory == NULL) (gdb) p memory $4 = (void *) 0x0