[Pythonmac-SIG] test_builtin hanging on 10.2

Brian Lenihan brian_l@mac.com
Mon, 7 Oct 2002 18:29:30 -0700 (PDT)


I filed a bug a SF against Python on this (61069).  It's debatable whether
this is Python's fault, but I believe the test in test_b1.py which is
causing the problem should not be run an every platform.

I'm going to avoid the problem by setting a hard limit of 400MB for per
process memory. 

bash: ulimit -v  nnnn
tcsh: limit datasize nnnn

The only way I know to break out of this is to run top in separate console
window before you start python (otherwise it will take a long time to
appear) and kill the python process once it starts swapping.  Your system is
not hung, it is just very busy doing page outs.

According the Apple's docs, lazy memory allocation and the 4GB of per
process virtual memory, are by design:

http://developer.apple.com/techpubs/macosx/Essentials/Performance/VirtualMemory/Virtual_Mem_on_Mac_OS_X.html
 
On Monday, Oct 07, 2002, at 08:08AM, Jack Jansen <Jack.Jansen@cwi.nl> wrote:

>I'm consistently seeing a hang, often even a complete system hang, i.e. 
>even cmd-alt-esc doesn't work anymore, if I run test_builtin under 10.2 
>(in the unix interpreter, both 10.2 and 10.2.1). Is anyone else seeing 
>this?
>
>What seems to be happening is that 10.2 (unlike 10.1) overcommits 
>virtual memory, and then finds itself in deep trouble when the memory 
>is actually used. Other programs (even the cmd-alt-esc handler) are 
>then locked out as soon as they need memory (or something similar). 
>test_builtin triggers this when it tries to create a list of 2**29 
>integers. The attached C program also triggers it. If you have, say, 
>1GB of freespace on your system drive the C program will run normally 
>upto iteration 1000 (it allocates a megabyte per iteration) and then 
>the system will come to a grinding halt.
>
>Before I submit a bug report to Apple: is anyone else seeing this? Is 
>anyone aware of more info on the problem? Is there any way out of the 
>hang short of the reset button?
>
>#include <stdio.h>
#include <stdlib.h>

main() {
	int i = 1;
	char *p;
	
	while(1) {
		p = malloc(1024*1024);
		if (p) {
			memset(p, 1, 1024*1024);
			printf("GOOD %5d 0x%x\n", i, p);
		} else {
			printf("NULL %5d\n", i);
			sleep(1);
		}
		i++;
	}
}
>