RE: Recursive malloc crashing Linux. (Well almost)

David Schwartz (davids@webmaster.com)
Fri, 17 Dec 1999 21:51:48 -0800


> My program (killmem.c, attached) doesn't recurse.
>
> It allocates (in a loop) lots of memory in 4MB chunk mmaps. (1GB total)
> It then fills each chunk one at a time until it dies.
> This demonstrates the ability to allocate far more memory than is
> available, and subsequently die when accessing it. This is overcommit,
> even when overcommit is turned off.
>
> Allocating memory in a single 1GB chunk fails gracefully, but allocating
> in 4MB chunks works until you access it.

*Yawn* You've written a program that manages to kill itself by shooting
itself in the foot. I can to that too:

char *j=NULL;
*j++;

Yes, Linux will overcommit even when overcommitting is turned off. There
really is no good way to solve this problem.

DS

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/